From patchwork Mon May 11 21:01:25 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lubomir Rintel X-Patchwork-Id: 200770 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6DE94C54E4B for ; Mon, 11 May 2020 21:02:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5B5E72078A for ; Mon, 11 May 2020 21:02:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731844AbgEKVCi (ORCPT ); Mon, 11 May 2020 17:02:38 -0400 Received: from v6.sk ([167.172.42.174]:52562 "EHLO v6.sk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729143AbgEKVBm (ORCPT ); Mon, 11 May 2020 17:01:42 -0400 Received: from localhost (v6.sk [IPv6:::1]) by v6.sk (Postfix) with ESMTP id 48001610D0; Mon, 11 May 2020 21:01:40 +0000 (UTC) From: Lubomir Rintel To: Liam Girdwood Cc: Mark Brown , Michael Turquette , Stephen Boyd , Rob Herring , linux-clk@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-media@vger.kernel.org, Lubomir Rintel Subject: [PATCH 02/11] ASoC: mmp-sspa: Drop S20_3LE case Date: Mon, 11 May 2020 23:01:25 +0200 Message-Id: <20200511210134.1224532-3-lkundrak@v3.sk> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200511210134.1224532-1-lkundrak@v3.sk> References: <20200511210134.1224532-1-lkundrak@v3.sk> MIME-Version: 1.0 Sender: devicetree-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org It does nothing, because the corresponding bit s not flipped on in .formats and the audio SRAM DMA engine is not able to handle 20-bit transfers anyway. Signed-off-by: Lubomir Rintel --- sound/soc/pxa/mmp-sspa.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/sound/soc/pxa/mmp-sspa.c b/sound/soc/pxa/mmp-sspa.c index 1ca6afe464c4..90a9bc81be80 100644 --- a/sound/soc/pxa/mmp-sspa.c +++ b/sound/soc/pxa/mmp-sspa.c @@ -275,9 +275,6 @@ static int mmp_sspa_hw_params(struct snd_pcm_substream *substream, case SNDRV_PCM_FORMAT_S16_LE: sspa_ctrl |= SSPA_CTL_XSSZ1(SSPA_CTL_16_BITS); break; - case SNDRV_PCM_FORMAT_S20_3LE: - sspa_ctrl |= SSPA_CTL_XSSZ1(SSPA_CTL_20_BITS); - break; case SNDRV_PCM_FORMAT_S24_3LE: sspa_ctrl |= SSPA_CTL_XSSZ1(SSPA_CTL_24_BITS); break; From patchwork Mon May 11 21:01:28 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lubomir Rintel X-Patchwork-Id: 200772 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DB55CC54E8D for ; Mon, 11 May 2020 21:02:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C737520836 for ; Mon, 11 May 2020 21:02:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732353AbgEKVBr (ORCPT ); Mon, 11 May 2020 17:01:47 -0400 Received: from v6.sk ([167.172.42.174]:52574 "EHLO v6.sk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732339AbgEKVBq (ORCPT ); Mon, 11 May 2020 17:01:46 -0400 Received: from localhost (v6.sk [IPv6:::1]) by v6.sk (Postfix) with ESMTP id BA2E6610D2; Mon, 11 May 2020 21:01:44 +0000 (UTC) From: Lubomir Rintel To: Liam Girdwood Cc: Mark Brown , Michael Turquette , Stephen Boyd , Rob Herring , linux-clk@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-media@vger.kernel.org, Lubomir Rintel Subject: [PATCH 05/11] ASoC: mmp-sspa: Add support for soc-generic-dmaengine-pcm Date: Mon, 11 May 2020 23:01:28 +0200 Message-Id: <20200511210134.1224532-6-lkundrak@v3.sk> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200511210134.1224532-1-lkundrak@v3.sk> References: <20200511210134.1224532-1-lkundrak@v3.sk> MIME-Version: 1.0 Sender: devicetree-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org This makes the driver usable with the mmp_tdma drier via soc-generic-dmaengine-pcm. This is conditionalized on DT node (support for DT is added by a later patch). A custom mmap callback that creates a NC mapping is used instead of the default WC one, because with write-combining some bytes don't seem to make it through for reasons unknown to me. Signed-off-by: Lubomir Rintel --- sound/soc/pxa/mmp-sspa.c | 57 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) diff --git a/sound/soc/pxa/mmp-sspa.c b/sound/soc/pxa/mmp-sspa.c index 421ffa9fa7b1..6e4b63d0c589 100644 --- a/sound/soc/pxa/mmp-sspa.c +++ b/sound/soc/pxa/mmp-sspa.c @@ -386,8 +386,54 @@ static struct snd_soc_dai_driver mmp_sspa_dai = { .ops = &mmp_sspa_dai_ops, }; +#define MMP_PCM_INFO (SNDRV_PCM_INFO_MMAP | \ + SNDRV_PCM_INFO_MMAP_VALID | \ + SNDRV_PCM_INFO_INTERLEAVED | \ + SNDRV_PCM_INFO_PAUSE | \ + SNDRV_PCM_INFO_RESUME | \ + SNDRV_PCM_INFO_NO_PERIOD_WAKEUP) + +static const struct snd_pcm_hardware mmp_pcm_hardware[] = { + { + .info = MMP_PCM_INFO, + .period_bytes_min = 1024, + .period_bytes_max = 2048, + .periods_min = 2, + .periods_max = 32, + .buffer_bytes_max = 4096, + .fifo_size = 32, + }, + { + .info = MMP_PCM_INFO, + .period_bytes_min = 1024, + .period_bytes_max = 2048, + .periods_min = 2, + .periods_max = 32, + .buffer_bytes_max = 4096, + .fifo_size = 32, + }, +}; + +static const struct snd_dmaengine_pcm_config mmp_pcm_config = { + .prepare_slave_config = snd_dmaengine_pcm_prepare_slave_config, + .pcm_hardware = mmp_pcm_hardware, + .prealloc_buffer_size = 4096, +}; + +static int mmp_pcm_mmap(struct snd_soc_component *component, + struct snd_pcm_substream *substream, + struct vm_area_struct *vma) +{ + vma->vm_flags |= VM_DONTEXPAND | VM_DONTDUMP; + vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot); + return remap_pfn_range(vma, vma->vm_start, + substream->dma_buffer.addr >> PAGE_SHIFT, + vma->vm_end - vma->vm_start, vma->vm_page_prot); +} + static const struct snd_soc_component_driver mmp_sspa_component = { .name = "mmp-sspa", + .mmap = mmp_pcm_mmap, }; static int asoc_mmp_sspa_probe(struct platform_device *pdev) @@ -425,10 +471,21 @@ static int asoc_mmp_sspa_probe(struct platform_device *pdev) priv->dai_fmt = (unsigned int) -1; platform_set_drvdata(pdev, priv); + priv->playback_dma_data.maxburst = 4; + priv->capture_dma_data.maxburst = 4; /* You know, these addresses are actually ignored. */ priv->playback_dma_data.addr = SSPA_TXD; priv->capture_dma_data.addr = SSPA_RXD; + if (pdev->dev.of_node) { + int ret; + + ret = devm_snd_dmaengine_pcm_register(&pdev->dev, + &mmp_pcm_config, 0); + if (ret) + return ret; + } + return devm_snd_soc_register_component(&pdev->dev, &mmp_sspa_component, &mmp_sspa_dai, 1); } From patchwork Mon May 11 21:01:29 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lubomir Rintel X-Patchwork-Id: 200773 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id AAC35C54E90 for ; Mon, 11 May 2020 21:02:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 966C920836 for ; Mon, 11 May 2020 21:02:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732359AbgEKVBt (ORCPT ); Mon, 11 May 2020 17:01:49 -0400 Received: from v6.sk ([167.172.42.174]:52586 "EHLO v6.sk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732346AbgEKVBs (ORCPT ); Mon, 11 May 2020 17:01:48 -0400 Received: from localhost (v6.sk [IPv6:::1]) by v6.sk (Postfix) with ESMTP id 524CE610D3; Mon, 11 May 2020 21:01:46 +0000 (UTC) From: Lubomir Rintel To: Liam Girdwood Cc: Mark Brown , Michael Turquette , Stephen Boyd , Rob Herring , linux-clk@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-media@vger.kernel.org, Lubomir Rintel Subject: [PATCH 06/11] ASoC: mmp-sspa: Remove the embedded struct ssp_device Date: Mon, 11 May 2020 23:01:29 +0200 Message-Id: <20200511210134.1224532-7-lkundrak@v3.sk> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200511210134.1224532-1-lkundrak@v3.sk> References: <20200511210134.1224532-1-lkundrak@v3.sk> MIME-Version: 1.0 Sender: devicetree-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org The "serial port" it represents is actually a SPI controller -- it's not clear why would the audio serial interface embed it. We're only using the mmio_base and clk fields. Signed-off-by: Lubomir Rintel --- sound/soc/pxa/mmp-sspa.c | 129 ++++++++++++++++++--------------------- 1 file changed, 60 insertions(+), 69 deletions(-) diff --git a/sound/soc/pxa/mmp-sspa.c b/sound/soc/pxa/mmp-sspa.c index 6e4b63d0c589..7a706b1d2588 100644 --- a/sound/soc/pxa/mmp-sspa.c +++ b/sound/soc/pxa/mmp-sspa.c @@ -11,7 +11,6 @@ #include #include #include -#include #include #include @@ -28,26 +27,27 @@ * SSPA audio private data */ struct sspa_priv { - struct ssp_device *sspa; + void __iomem *mmio_base; struct snd_dmaengine_dai_dma_data playback_dma_data; struct snd_dmaengine_dai_dma_data capture_dma_data; + struct clk *clk; struct clk *audio_clk; struct clk *sysclk; int dai_fmt; int running_cnt; }; -static void mmp_sspa_write_reg(struct ssp_device *sspa, u32 reg, u32 val) +static void mmp_sspa_write_reg(struct sspa_priv *sspa, u32 reg, u32 val) { __raw_writel(val, sspa->mmio_base + reg); } -static u32 mmp_sspa_read_reg(struct ssp_device *sspa, u32 reg) +static u32 mmp_sspa_read_reg(struct sspa_priv *sspa, u32 reg) { return __raw_readl(sspa->mmio_base + reg); } -static void mmp_sspa_tx_enable(struct ssp_device *sspa) +static void mmp_sspa_tx_enable(struct sspa_priv *sspa) { unsigned int sspa_sp; @@ -57,7 +57,7 @@ static void mmp_sspa_tx_enable(struct ssp_device *sspa) mmp_sspa_write_reg(sspa, SSPA_TXSP, sspa_sp); } -static void mmp_sspa_tx_disable(struct ssp_device *sspa) +static void mmp_sspa_tx_disable(struct sspa_priv *sspa) { unsigned int sspa_sp; @@ -67,7 +67,7 @@ static void mmp_sspa_tx_disable(struct ssp_device *sspa) mmp_sspa_write_reg(sspa, SSPA_TXSP, sspa_sp); } -static void mmp_sspa_rx_enable(struct ssp_device *sspa) +static void mmp_sspa_rx_enable(struct sspa_priv *sspa) { unsigned int sspa_sp; @@ -77,7 +77,7 @@ static void mmp_sspa_rx_enable(struct ssp_device *sspa) mmp_sspa_write_reg(sspa, SSPA_RXSP, sspa_sp); } -static void mmp_sspa_rx_disable(struct ssp_device *sspa) +static void mmp_sspa_rx_disable(struct sspa_priv *sspa) { unsigned int sspa_sp; @@ -90,10 +90,10 @@ static void mmp_sspa_rx_disable(struct ssp_device *sspa) static int mmp_sspa_startup(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { - struct sspa_priv *priv = snd_soc_dai_get_drvdata(dai); + struct sspa_priv *sspa = snd_soc_dai_get_drvdata(dai); - clk_enable(priv->sysclk); - clk_enable(priv->sspa->clk); + clk_enable(sspa->sysclk); + clk_enable(sspa->clk); return 0; } @@ -101,10 +101,10 @@ static int mmp_sspa_startup(struct snd_pcm_substream *substream, static void mmp_sspa_shutdown(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { - struct sspa_priv *priv = snd_soc_dai_get_drvdata(dai); + struct sspa_priv *sspa = snd_soc_dai_get_drvdata(dai); - clk_disable(priv->sspa->clk); - clk_disable(priv->sysclk); + clk_disable(sspa->clk); + clk_disable(sspa->sysclk); } @@ -114,12 +114,12 @@ static void mmp_sspa_shutdown(struct snd_pcm_substream *substream, static int mmp_sspa_set_dai_sysclk(struct snd_soc_dai *cpu_dai, int clk_id, unsigned int freq, int dir) { - struct sspa_priv *priv = snd_soc_dai_get_drvdata(cpu_dai); + struct sspa_priv *sspa = snd_soc_dai_get_drvdata(cpu_dai); int ret = 0; switch (clk_id) { case MMP_SSPA_CLK_AUDIO: - ret = clk_set_rate(priv->audio_clk, freq); + ret = clk_set_rate(sspa->audio_clk, freq); if (ret) return ret; break; @@ -138,17 +138,17 @@ static int mmp_sspa_set_dai_pll(struct snd_soc_dai *cpu_dai, int pll_id, int source, unsigned int freq_in, unsigned int freq_out) { - struct sspa_priv *priv = snd_soc_dai_get_drvdata(cpu_dai); + struct sspa_priv *sspa = snd_soc_dai_get_drvdata(cpu_dai); int ret = 0; switch (pll_id) { case MMP_SYSCLK: - ret = clk_set_rate(priv->sysclk, freq_out); + ret = clk_set_rate(sspa->sysclk, freq_out); if (ret) return ret; break; case MMP_SSPA_CLK: - ret = clk_set_rate(priv->sspa->clk, freq_out); + ret = clk_set_rate(sspa->clk, freq_out); if (ret) return ret; break; @@ -167,18 +167,17 @@ static int mmp_sspa_set_dai_pll(struct snd_soc_dai *cpu_dai, int pll_id, static int mmp_sspa_set_dai_fmt(struct snd_soc_dai *cpu_dai, unsigned int fmt) { - struct sspa_priv *sspa_priv = snd_soc_dai_get_drvdata(cpu_dai); - struct ssp_device *sspa = sspa_priv->sspa; + struct sspa_priv *sspa = snd_soc_dai_get_drvdata(cpu_dai); u32 sspa_sp, sspa_ctrl; /* check if we need to change anything at all */ - if (sspa_priv->dai_fmt == fmt) + if (sspa->dai_fmt == fmt) return 0; /* we can only change the settings if the port is not in use */ if ((mmp_sspa_read_reg(sspa, SSPA_TXSP) & SSPA_SP_S_EN) || (mmp_sspa_read_reg(sspa, SSPA_RXSP) & SSPA_SP_S_EN)) { - dev_err(sspa->dev, + dev_err(cpu_dai->dev, "can't change hardware dai format: stream is in use\n"); return -EINVAL; } @@ -239,7 +238,7 @@ static int mmp_sspa_set_dai_fmt(struct snd_soc_dai *cpu_dai, * we have to defer some things until hw_params() where we * know parameters like the sample size. */ - sspa_priv->dai_fmt = fmt; + sspa->dai_fmt = fmt; return 0; } @@ -251,8 +250,7 @@ static int mmp_sspa_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { - struct sspa_priv *sspa_priv = snd_soc_dai_get_drvdata(dai); - struct ssp_device *sspa = sspa_priv->sspa; + struct sspa_priv *sspa = snd_soc_dai_get_drvdata(dai); u32 sspa_ctrl; if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) @@ -297,8 +295,7 @@ static int mmp_sspa_hw_params(struct snd_pcm_substream *substream, static int mmp_sspa_trigger(struct snd_pcm_substream *substream, int cmd, struct snd_soc_dai *dai) { - struct sspa_priv *sspa_priv = snd_soc_dai_get_drvdata(dai); - struct ssp_device *sspa = sspa_priv->sspa; + struct sspa_priv *sspa = snd_soc_dai_get_drvdata(dai); int ret = 0; switch (cmd) { @@ -311,25 +308,25 @@ static int mmp_sspa_trigger(struct snd_pcm_substream *substream, int cmd, * enabled or not; if has been enabled by another * stream, do not enable again. */ - if (!sspa_priv->running_cnt) + if (!sspa->running_cnt) mmp_sspa_rx_enable(sspa); if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) mmp_sspa_tx_enable(sspa); - sspa_priv->running_cnt++; + sspa->running_cnt++; break; case SNDRV_PCM_TRIGGER_STOP: case SNDRV_PCM_TRIGGER_SUSPEND: case SNDRV_PCM_TRIGGER_PAUSE_PUSH: - sspa_priv->running_cnt--; + sspa->running_cnt--; if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) mmp_sspa_tx_disable(sspa); /* have no capture stream, disable rx port */ - if (!sspa_priv->running_cnt) + if (!sspa->running_cnt) mmp_sspa_rx_disable(sspa); break; @@ -342,15 +339,14 @@ static int mmp_sspa_trigger(struct snd_pcm_substream *substream, int cmd, static int mmp_sspa_probe(struct snd_soc_dai *dai) { - struct sspa_priv *priv = dev_get_drvdata(dai->dev); + struct sspa_priv *sspa = dev_get_drvdata(dai->dev); snd_soc_dai_init_dma_data(dai, - &priv->playback_dma_data, - &priv->capture_dma_data); + &sspa->playback_dma_data, + &sspa->capture_dma_data); - snd_soc_dai_set_drvdata(dai, priv); + snd_soc_dai_set_drvdata(dai, sspa); return 0; - } #define MMP_SSPA_RATES SNDRV_PCM_RATE_8000_192000 @@ -438,44 +434,39 @@ static const struct snd_soc_component_driver mmp_sspa_component = { static int asoc_mmp_sspa_probe(struct platform_device *pdev) { - struct sspa_priv *priv; + struct sspa_priv *sspa; - priv = devm_kzalloc(&pdev->dev, + sspa = devm_kzalloc(&pdev->dev, sizeof(struct sspa_priv), GFP_KERNEL); - if (!priv) + if (!sspa) return -ENOMEM; - priv->sspa = devm_kzalloc(&pdev->dev, - sizeof(struct ssp_device), GFP_KERNEL); - if (priv->sspa == NULL) - return -ENOMEM; + sspa->mmio_base = devm_platform_ioremap_resource(pdev, 0); + if (IS_ERR(sspa->mmio_base)) + return PTR_ERR(sspa->mmio_base); - priv->sspa->mmio_base = devm_platform_ioremap_resource(pdev, 0); - if (IS_ERR(priv->sspa->mmio_base)) - return PTR_ERR(priv->sspa->mmio_base); + sspa->clk = devm_clk_get(&pdev->dev, NULL); + if (IS_ERR(sspa->clk)) + return PTR_ERR(sspa->clk); - priv->sspa->clk = devm_clk_get(&pdev->dev, NULL); - if (IS_ERR(priv->sspa->clk)) - return PTR_ERR(priv->sspa->clk); + sspa->audio_clk = clk_get(NULL, "mmp-audio"); + if (IS_ERR(sspa->audio_clk)) + return PTR_ERR(sspa->audio_clk); - priv->audio_clk = clk_get(NULL, "mmp-audio"); - if (IS_ERR(priv->audio_clk)) - return PTR_ERR(priv->audio_clk); - - priv->sysclk = clk_get(NULL, "mmp-sysclk"); - if (IS_ERR(priv->sysclk)) { - clk_put(priv->audio_clk); - return PTR_ERR(priv->sysclk); + sspa->sysclk = clk_get(NULL, "mmp-sysclk"); + if (IS_ERR(sspa->sysclk)) { + clk_put(sspa->audio_clk); + return PTR_ERR(sspa->sysclk); } - clk_enable(priv->audio_clk); - priv->dai_fmt = (unsigned int) -1; - platform_set_drvdata(pdev, priv); + clk_enable(sspa->audio_clk); + sspa->dai_fmt = (unsigned int) -1; + platform_set_drvdata(pdev, sspa); - priv->playback_dma_data.maxburst = 4; - priv->capture_dma_data.maxburst = 4; + sspa->playback_dma_data.maxburst = 4; + sspa->capture_dma_data.maxburst = 4; /* You know, these addresses are actually ignored. */ - priv->playback_dma_data.addr = SSPA_TXD; - priv->capture_dma_data.addr = SSPA_RXD; + sspa->playback_dma_data.addr = SSPA_TXD; + sspa->capture_dma_data.addr = SSPA_RXD; if (pdev->dev.of_node) { int ret; @@ -492,11 +483,11 @@ static int asoc_mmp_sspa_probe(struct platform_device *pdev) static int asoc_mmp_sspa_remove(struct platform_device *pdev) { - struct sspa_priv *priv = platform_get_drvdata(pdev); + struct sspa_priv *sspa = platform_get_drvdata(pdev); - clk_disable(priv->audio_clk); - clk_put(priv->audio_clk); - clk_put(priv->sysclk); + clk_disable(sspa->audio_clk); + clk_put(sspa->audio_clk); + clk_put(sspa->sysclk); return 0; } From patchwork Mon May 11 21:01:32 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lubomir Rintel X-Patchwork-Id: 200774 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 71A6DC54E90 for ; Mon, 11 May 2020 21:01:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5E9CD20836 for ; Mon, 11 May 2020 21:01:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732379AbgEKVBy (ORCPT ); Mon, 11 May 2020 17:01:54 -0400 Received: from v6.sk ([167.172.42.174]:52638 "EHLO v6.sk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732371AbgEKVBw (ORCPT ); Mon, 11 May 2020 17:01:52 -0400 Received: from localhost (v6.sk [IPv6:::1]) by v6.sk (Postfix) with ESMTP id 1ACDF610D5; Mon, 11 May 2020 21:01:51 +0000 (UTC) From: Lubomir Rintel To: Liam Girdwood Cc: Mark Brown , Michael Turquette , Stephen Boyd , Rob Herring , linux-clk@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-media@vger.kernel.org, Lubomir Rintel Subject: [PATCH 09/11] ASoC: mmp-sspa: Set appropriate bus format for given bit width Date: Mon, 11 May 2020 23:01:32 +0200 Message-Id: <20200511210134.1224532-10-lkundrak@v3.sk> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200511210134.1224532-1-lkundrak@v3.sk> References: <20200511210134.1224532-1-lkundrak@v3.sk> MIME-Version: 1.0 Sender: devicetree-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org The values set by set_dai_fmt() and hw_params() seem to be tailored only for 32-bit formats. Negotiate the correct ones in hw_params() callback instead. This was essentially copied from the OLPC kernel driver and tested to fix wrong audio output for non-32bit formats. The documentation is not available. Signed-off-by: Lubomir Rintel --- sound/soc/pxa/mmp-sspa.c | 40 ++++++++++++++++++++++++++++------------ sound/soc/pxa/mmp-sspa.h | 2 ++ 2 files changed, 30 insertions(+), 12 deletions(-) diff --git a/sound/soc/pxa/mmp-sspa.c b/sound/soc/pxa/mmp-sspa.c index 9cb17c4fb0c8..86277471974a 100644 --- a/sound/soc/pxa/mmp-sspa.c +++ b/sound/soc/pxa/mmp-sspa.c @@ -191,8 +191,6 @@ static int mmp_sspa_set_dai_fmt(struct snd_soc_dai *cpu_dai, switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) { case SND_SOC_DAIFMT_I2S: - sspa->sp |= SSPA_TXSP_FPER(63); - sspa->sp |= SSPA_SP_FWID(31); sspa->ctrl |= SSPA_CTL_XDATDLY(1); break; default: @@ -216,30 +214,48 @@ static int mmp_sspa_hw_params(struct snd_pcm_substream *substream, { struct sspa_priv *sspa = snd_soc_dai_get_drvdata(dai); u32 sspa_ctrl = sspa->ctrl; - - sspa_ctrl &= ~SSPA_CTL_XFRLEN1_MASK; - sspa_ctrl |= SSPA_CTL_XFRLEN1(params_channels(params) - 1); - sspa_ctrl &= ~SSPA_CTL_XWDLEN1_MASK; - sspa_ctrl |= SSPA_CTL_XWDLEN1(SSPA_CTL_32_BITS); - sspa_ctrl &= ~SSPA_CTL_XSSZ1_MASK; + int bits; + int bitval; switch (params_format(params)) { case SNDRV_PCM_FORMAT_S8: - sspa_ctrl |= SSPA_CTL_XSSZ1(SSPA_CTL_8_BITS); + bits = 8; + bitval = SSPA_CTL_8_BITS; break; case SNDRV_PCM_FORMAT_S16_LE: - sspa_ctrl |= SSPA_CTL_XSSZ1(SSPA_CTL_16_BITS); + bits = 16; + bitval = SSPA_CTL_16_BITS; break; case SNDRV_PCM_FORMAT_S24_3LE: - sspa_ctrl |= SSPA_CTL_XSSZ1(SSPA_CTL_24_BITS); + bits = 24; + bitval = SSPA_CTL_24_BITS; break; case SNDRV_PCM_FORMAT_S32_LE: - sspa_ctrl |= SSPA_CTL_XSSZ1(SSPA_CTL_32_BITS); + bits = 32; + bitval = SSPA_CTL_32_BITS; break; default: return -EINVAL; } + if (params_channels(params) == 2) + sspa_ctrl |= SSPA_CTL_XPH; + + sspa_ctrl &= ~SSPA_CTL_XWDLEN1_MASK; + sspa_ctrl |= SSPA_CTL_XWDLEN1(bitval); + + sspa_ctrl &= ~SSPA_CTL_XSSZ1_MASK; + sspa_ctrl |= SSPA_CTL_XSSZ1(bitval); + + sspa_ctrl &= ~SSPA_CTL_XSSZ2_MASK; + sspa_ctrl |= SSPA_CTL_XSSZ2(bitval); + + sspa->sp &= ~SSPA_SP_FWID_MASK; + sspa->sp |= SSPA_SP_FWID(bits - 1); + + sspa->sp &= ~SSPA_TXSP_FPER_MASK; + sspa->sp |= SSPA_TXSP_FPER(bits * 2 - 1); + if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { mmp_sspa_write_reg(sspa, SSPA_TXCTL, sspa_ctrl); mmp_sspa_write_reg(sspa, SSPA_TXFIFO_LL, 0x1); diff --git a/sound/soc/pxa/mmp-sspa.h b/sound/soc/pxa/mmp-sspa.h index 611063a7af68..328969b57ad1 100644 --- a/sound/soc/pxa/mmp-sspa.h +++ b/sound/soc/pxa/mmp-sspa.h @@ -63,7 +63,9 @@ #define SSPA_SP_FFLUSH (1 << 2) /* FIFO Flush */ #define SSPA_SP_S_RST (1 << 1) /* Active High Reset Signal */ #define SSPA_SP_S_EN (1 << 0) /* Serial Clock Domain Enable */ +#define SSPA_SP_FWID_MASK (0x3f << 20) #define SSPA_SP_FWID(x) ((x) << 20) /* Frame-Sync Width */ +#define SSPA_TXSP_FPER_MASK (0x3f << 4) #define SSPA_TXSP_FPER(x) ((x) << 4) /* Frame-Sync Active */ /* sspa clock sources */ From patchwork Mon May 11 21:01:34 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lubomir Rintel X-Patchwork-Id: 200771 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 652C8C47255 for ; Mon, 11 May 2020 21:02:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4BB502078A for ; Mon, 11 May 2020 21:02:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732344AbgEKVC2 (ORCPT ); Mon, 11 May 2020 17:02:28 -0400 Received: from v6.sk ([167.172.42.174]:52682 "EHLO v6.sk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728544AbgEKVC2 (ORCPT ); Mon, 11 May 2020 17:02:28 -0400 Received: from localhost (v6.sk [IPv6:::1]) by v6.sk (Postfix) with ESMTP id 2ED03610D6; Mon, 11 May 2020 21:01:54 +0000 (UTC) From: Lubomir Rintel To: Liam Girdwood Cc: Mark Brown , Michael Turquette , Stephen Boyd , Rob Herring , linux-clk@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-media@vger.kernel.org, Lubomir Rintel Subject: [PATCH 11/11] ASoC: mmp-sspa: Add Device Tree support Date: Mon, 11 May 2020 23:01:34 +0200 Message-Id: <20200511210134.1224532-12-lkundrak@v3.sk> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200511210134.1224532-1-lkundrak@v3.sk> References: <20200511210134.1224532-1-lkundrak@v3.sk> MIME-Version: 1.0 Sender: devicetree-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org This makes it possible to select CONFIG_SND_MMP_SOC_SSPA directly, as opposed to via CONFIG_SND_MMP_SOC, and for the driver to bind to a device tree node. That makes the driver useful on Device Tree based systems, with audio-graph-card or simple-card. The aforementioned card drivers control the master clock themselves and don't call the set_dai_sysclk() or set_dai_pll(), thus the respective handlers don't serve any purpose anymore. Instead, they return early and the hw_params() handler sets the appropriate bitclk itself. The register range is split into two -- for the RX block and for the TX block. On a MMP2 there are two pairs of them; the first one has the clock controller in the middle, while the second just has a hole: 0xd42a0c00 - 0xd42a0c30 RX1 0xd42a0c30 - 0xd42a0c40 Clocks 0xd42a0c80 - 0xd42a0cb0 TX1 0xd42a0d00 - 0xd42a0d30 RX2 0xd42a0d80 - 0xd42a0cb0 TX2 For this reason, mmp_sspa_write_reg() and mmp_sspa_read_reg() are replaced with direct calls to I/O routines. Tested on a MMP2-based OLPC XO-1.75 laptop with rt5631 coded, mmp_tdma DMA engine and MMP2 clock controller glued together with audio-graph-card. Signed-off-by: Lubomir Rintel --- sound/soc/pxa/Kconfig | 20 +++--- sound/soc/pxa/mmp-sspa.c | 139 ++++++++++++++++++++++++++------------- sound/soc/pxa/mmp-sspa.h | 28 +++----- 3 files changed, 113 insertions(+), 74 deletions(-) diff --git a/sound/soc/pxa/Kconfig b/sound/soc/pxa/Kconfig index d4c0f580a565..7ad2fd7e653b 100644 --- a/sound/soc/pxa/Kconfig +++ b/sound/soc/pxa/Kconfig @@ -9,14 +9,8 @@ config SND_PXA2XX_SOC to select the audio interfaces to support below. config SND_MMP_SOC - bool "Soc Audio for Marvell MMP chips" - depends on ARCH_MMP + bool select MMP_SRAM - select SND_SOC_GENERIC_DMAENGINE_PCM - select SND_ARM - help - Say Y if you want to add support for codecs attached to - the MMP SSPA interface. config SND_PXA2XX_AC97 tristate @@ -39,7 +33,13 @@ config SND_PXA_SOC_SSP select SND_PXA2XX_LIB config SND_MMP_SOC_SSPA - tristate + tristate "SoC Audio via MMP SSPA ports" + depends on ARCH_MMP + select SND_SOC_GENERIC_DMAENGINE_PCM + select SND_ARM + help + Say Y if you want to add support for codecs attached to + the MMP SSPA interface. config SND_PXA2XX_SOC_CORGI tristate "SoC Audio support for Sharp Zaurus SL-C7x0" @@ -232,8 +232,8 @@ config SND_PXA2XX_SOC_IMOTE2 config SND_MMP_SOC_BROWNSTONE tristate "SoC Audio support for Marvell Brownstone" - depends on SND_MMP_SOC && MACH_BROWNSTONE && I2C - select SND_MMP_SOC_SSPA + depends on SND_MMP_SOC_SSPA && MACH_BROWNSTONE && I2C + select SND_MMP_SOC select MFD_WM8994 select SND_SOC_WM8994 help diff --git a/sound/soc/pxa/mmp-sspa.c b/sound/soc/pxa/mmp-sspa.c index 86277471974a..b0accd49c89d 100644 --- a/sound/soc/pxa/mmp-sspa.c +++ b/sound/soc/pxa/mmp-sspa.c @@ -28,27 +28,20 @@ * SSPA audio private data */ struct sspa_priv { - void __iomem *mmio_base; + void __iomem *tx_base; + void __iomem *rx_base; + struct snd_dmaengine_dai_dma_data playback_dma_data; struct snd_dmaengine_dai_dma_data capture_dma_data; struct clk *clk; struct clk *audio_clk; struct clk *sysclk; + int running_cnt; u32 sp; u32 ctrl; }; -static void mmp_sspa_write_reg(struct sspa_priv *sspa, u32 reg, u32 val) -{ - __raw_writel(val, sspa->mmio_base + reg); -} - -static u32 mmp_sspa_read_reg(struct sspa_priv *sspa, u32 reg) -{ - return __raw_readl(sspa->mmio_base + reg); -} - static void mmp_sspa_tx_enable(struct sspa_priv *sspa) { unsigned int sspa_sp = sspa->sp; @@ -56,7 +49,7 @@ static void mmp_sspa_tx_enable(struct sspa_priv *sspa) sspa_sp &= ~SSPA_SP_MSL; sspa_sp |= SSPA_SP_S_EN; sspa_sp |= SSPA_SP_WEN; - mmp_sspa_write_reg(sspa, SSPA_TXSP, sspa_sp); + __raw_writel(sspa_sp, sspa->tx_base + SSPA_SP); } static void mmp_sspa_tx_disable(struct sspa_priv *sspa) @@ -66,7 +59,7 @@ static void mmp_sspa_tx_disable(struct sspa_priv *sspa) sspa_sp &= ~SSPA_SP_MSL; sspa_sp &= ~SSPA_SP_S_EN; sspa_sp |= SSPA_SP_WEN; - mmp_sspa_write_reg(sspa, SSPA_TXSP, sspa_sp); + __raw_writel(sspa_sp, sspa->tx_base + SSPA_SP); } static void mmp_sspa_rx_enable(struct sspa_priv *sspa) @@ -75,7 +68,7 @@ static void mmp_sspa_rx_enable(struct sspa_priv *sspa) sspa_sp |= SSPA_SP_S_EN; sspa_sp |= SSPA_SP_WEN; - mmp_sspa_write_reg(sspa, SSPA_RXSP, sspa_sp); + __raw_writel(sspa_sp, sspa->rx_base + SSPA_SP); } static void mmp_sspa_rx_disable(struct sspa_priv *sspa) @@ -84,7 +77,7 @@ static void mmp_sspa_rx_disable(struct sspa_priv *sspa) sspa_sp &= ~SSPA_SP_S_EN; sspa_sp |= SSPA_SP_WEN; - mmp_sspa_write_reg(sspa, SSPA_RXSP, sspa_sp); + __raw_writel(sspa_sp, sspa->rx_base + SSPA_SP); } static int mmp_sspa_startup(struct snd_pcm_substream *substream, @@ -105,7 +98,6 @@ static void mmp_sspa_shutdown(struct snd_pcm_substream *substream, clk_disable_unprepare(sspa->clk); clk_disable_unprepare(sspa->sysclk); - } /* @@ -115,8 +107,12 @@ static int mmp_sspa_set_dai_sysclk(struct snd_soc_dai *cpu_dai, int clk_id, unsigned int freq, int dir) { struct sspa_priv *sspa = snd_soc_dai_get_drvdata(cpu_dai); + struct device *dev = cpu_dai->component->dev; int ret = 0; + if (dev->of_node) + return -ENOTSUPP; + switch (clk_id) { case MMP_SSPA_CLK_AUDIO: ret = clk_set_rate(sspa->audio_clk, freq); @@ -139,8 +135,12 @@ static int mmp_sspa_set_dai_pll(struct snd_soc_dai *cpu_dai, int pll_id, unsigned int freq_out) { struct sspa_priv *sspa = snd_soc_dai_get_drvdata(cpu_dai); + struct device *dev = cpu_dai->component->dev; int ret = 0; + if (dev->of_node) + return -ENOTSUPP; + switch (pll_id) { case MMP_SYSCLK: ret = clk_set_rate(sspa->sysclk, freq_out); @@ -213,6 +213,7 @@ static int mmp_sspa_hw_params(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { struct sspa_priv *sspa = snd_soc_dai_get_drvdata(dai); + struct device *dev = dai->component->dev; u32 sspa_ctrl = sspa->ctrl; int bits; int bitval; @@ -238,7 +239,7 @@ static int mmp_sspa_hw_params(struct snd_pcm_substream *substream, return -EINVAL; } - if (params_channels(params) == 2) + if (dev->of_node || params_channels(params) == 2) sspa_ctrl |= SSPA_CTL_XPH; sspa_ctrl &= ~SSPA_CTL_XWDLEN1_MASK; @@ -256,12 +257,17 @@ static int mmp_sspa_hw_params(struct snd_pcm_substream *substream, sspa->sp &= ~SSPA_TXSP_FPER_MASK; sspa->sp |= SSPA_TXSP_FPER(bits * 2 - 1); + if (dev->of_node) { + clk_set_rate(sspa->clk, params_rate(params) * + params_channels(params) * bits); + } + if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { - mmp_sspa_write_reg(sspa, SSPA_TXCTL, sspa_ctrl); - mmp_sspa_write_reg(sspa, SSPA_TXFIFO_LL, 0x1); + __raw_writel(sspa_ctrl, sspa->tx_base + SSPA_CTL); + __raw_writel(0x1, sspa->tx_base + SSPA_FIFO_UL); } else { - mmp_sspa_write_reg(sspa, SSPA_RXCTL, sspa_ctrl); - mmp_sspa_write_reg(sspa, SSPA_RXFIFO_UL, 0x0); + __raw_writel(sspa_ctrl, sspa->rx_base + SSPA_CTL); + __raw_writel(0x0, sspa->rx_base + SSPA_FIFO_UL); } return 0; @@ -410,19 +416,19 @@ static int mmp_sspa_open(struct snd_soc_component *component, pm_runtime_get_sync(component->dev); /* we can only change the settings if the port is not in use */ - if ((mmp_sspa_read_reg(sspa, SSPA_TXSP) & SSPA_SP_S_EN) || - (mmp_sspa_read_reg(sspa, SSPA_RXSP) & SSPA_SP_S_EN)) { + if ((__raw_readl(sspa->tx_base + SSPA_SP) & SSPA_SP_S_EN) || + (__raw_readl(sspa->rx_base + SSPA_SP) & SSPA_SP_S_EN)) { dev_err(component->dev, "can't change hardware dai format: stream is in use\n"); return -EBUSY; } - mmp_sspa_write_reg(sspa, SSPA_TXSP, sspa->sp); - mmp_sspa_write_reg(sspa, SSPA_RXSP, sspa->sp); + __raw_writel(sspa->sp, sspa->tx_base + SSPA_SP); + __raw_writel(sspa->sp, sspa->rx_base + SSPA_SP); sspa->sp &= ~(SSPA_SP_S_RST | SSPA_SP_FFLUSH); - mmp_sspa_write_reg(sspa, SSPA_TXSP, sspa->sp); - mmp_sspa_write_reg(sspa, SSPA_RXSP, sspa->sp); + __raw_writel(sspa->sp, sspa->tx_base + SSPA_SP); + __raw_writel(sspa->sp, sspa->rx_base + SSPA_SP); /* * FIXME: hw issue, for the tx serial port, @@ -431,10 +437,10 @@ static int mmp_sspa_open(struct snd_soc_component *component, * The master/slave mode has been set in the * rx port. */ - mmp_sspa_write_reg(sspa, SSPA_TXSP, sspa->sp & ~SSPA_SP_MSL); + __raw_writel(sspa->sp & ~SSPA_SP_MSL, sspa->tx_base + SSPA_SP); - mmp_sspa_write_reg(sspa, SSPA_TXCTL, sspa->ctrl); - mmp_sspa_write_reg(sspa, SSPA_RXCTL, sspa->ctrl); + __raw_writel(sspa->ctrl, sspa->tx_base + SSPA_CTL); + __raw_writel(sspa->ctrl, sspa->rx_base + SSPA_CTL); return 0; } @@ -462,22 +468,51 @@ static int asoc_mmp_sspa_probe(struct platform_device *pdev) if (!sspa) return -ENOMEM; - sspa->mmio_base = devm_platform_ioremap_resource(pdev, 0); - if (IS_ERR(sspa->mmio_base)) - return PTR_ERR(sspa->mmio_base); + if (pdev->dev.of_node) { + sspa->rx_base = devm_platform_ioremap_resource(pdev, 0); + if (IS_ERR(sspa->rx_base)) + return PTR_ERR(sspa->rx_base); - sspa->clk = devm_clk_get(&pdev->dev, NULL); - if (IS_ERR(sspa->clk)) - return PTR_ERR(sspa->clk); + sspa->tx_base = devm_platform_ioremap_resource(pdev, 1); + if (IS_ERR(sspa->tx_base)) + return PTR_ERR(sspa->tx_base); - sspa->audio_clk = clk_get(NULL, "mmp-audio"); - if (IS_ERR(sspa->audio_clk)) - return PTR_ERR(sspa->audio_clk); + sspa->clk = devm_clk_get(&pdev->dev, "bitclk"); + if (IS_ERR(sspa->clk)) + return PTR_ERR(sspa->clk); - sspa->sysclk = clk_get(NULL, "mmp-sysclk"); - if (IS_ERR(sspa->sysclk)) { - clk_put(sspa->audio_clk); - return PTR_ERR(sspa->sysclk); + sspa->audio_clk = devm_clk_get(&pdev->dev, "audio"); + if (IS_ERR(sspa->audio_clk)) + return PTR_ERR(sspa->audio_clk); + } else { + struct resource *res; + + res = platform_get_resource(pdev, IORESOURCE_IO, 0); + if (res == NULL) + return -ENODEV; + + sspa->rx_base = devm_ioremap(&pdev->dev, res->start, 0x30); + if (IS_ERR(sspa->rx_base)) + return PTR_ERR(sspa->rx_base); + + sspa->tx_base = devm_ioremap(&pdev->dev, + res->start + 0x80, 0x30); + if (IS_ERR(sspa->tx_base)) + return PTR_ERR(sspa->tx_base); + + sspa->clk = devm_clk_get(&pdev->dev, NULL); + if (IS_ERR(sspa->clk)) + return PTR_ERR(sspa->clk); + + sspa->audio_clk = clk_get(NULL, "mmp-audio"); + if (IS_ERR(sspa->audio_clk)) + return PTR_ERR(sspa->audio_clk); + + sspa->sysclk = clk_get(NULL, "mmp-sysclk"); + if (IS_ERR(sspa->sysclk)) { + clk_put(sspa->audio_clk); + return PTR_ERR(sspa->sysclk); + } } pm_runtime_enable(&pdev->dev); clk_prepare_enable(sspa->audio_clk); @@ -486,8 +521,8 @@ static int asoc_mmp_sspa_probe(struct platform_device *pdev) sspa->playback_dma_data.maxburst = 4; sspa->capture_dma_data.maxburst = 4; /* You know, these addresses are actually ignored. */ - sspa->playback_dma_data.addr = SSPA_TXD; - sspa->capture_dma_data.addr = SSPA_RXD; + sspa->capture_dma_data.addr = SSPA_D; + sspa->playback_dma_data.addr = 0x80 + SSPA_D; if (pdev->dev.of_node) { int ret; @@ -508,14 +543,28 @@ static int asoc_mmp_sspa_remove(struct platform_device *pdev) clk_disable_unprepare(sspa->audio_clk); pm_runtime_disable(&pdev->dev); + + if (pdev->dev.of_node) + return 0; + clk_put(sspa->audio_clk); clk_put(sspa->sysclk); return 0; } +#ifdef CONFIG_OF +static const struct of_device_id mmp_sspa_of_match[] = { + { .compatible = "marvell,mmp-sspa" }, + {}, +}; + +MODULE_DEVICE_TABLE(of, mmp_sspa_of_match); +#endif + static struct platform_driver asoc_mmp_sspa_driver = { .driver = { .name = "mmp-sspa-dai", + .of_match_table = of_match_ptr(mmp_sspa_of_match), }, .probe = asoc_mmp_sspa_probe, .remove = asoc_mmp_sspa_remove, diff --git a/sound/soc/pxa/mmp-sspa.h b/sound/soc/pxa/mmp-sspa.h index 328969b57ad1..938ef2f667e3 100644 --- a/sound/soc/pxa/mmp-sspa.h +++ b/sound/soc/pxa/mmp-sspa.h @@ -10,25 +10,15 @@ /* * SSPA Registers */ -#define SSPA_RXD (0x00) -#define SSPA_RXID (0x04) -#define SSPA_RXCTL (0x08) -#define SSPA_RXSP (0x0c) -#define SSPA_RXFIFO_UL (0x10) -#define SSPA_RXINT_MASK (0x14) -#define SSPA_RXC (0x18) -#define SSPA_RXFIFO_NOFS (0x1c) -#define SSPA_RXFIFO_SIZE (0x20) - -#define SSPA_TXD (0x80) -#define SSPA_TXID (0x84) -#define SSPA_TXCTL (0x88) -#define SSPA_TXSP (0x8c) -#define SSPA_TXFIFO_LL (0x90) -#define SSPA_TXINT_MASK (0x94) -#define SSPA_TXC (0x98) -#define SSPA_TXFIFO_NOFS (0x9c) -#define SSPA_TXFIFO_SIZE (0xa0) +#define SSPA_D (0x00) +#define SSPA_ID (0x04) +#define SSPA_CTL (0x08) +#define SSPA_SP (0x0c) +#define SSPA_FIFO_UL (0x10) +#define SSPA_INT_MASK (0x14) +#define SSPA_C (0x18) +#define SSPA_FIFO_NOFS (0x1c) +#define SSPA_FIFO_SIZE (0x20) /* SSPA Control Register */ #define SSPA_CTL_XPH (1 << 31) /* Read Phase */