From patchwork Mon Apr 14 13:35:38 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markus Pargmann X-Patchwork-Id: 3980961 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id DCFE19F2BA for ; Mon, 14 Apr 2014 13:39:13 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id D8169201D3 for ; Mon, 14 Apr 2014 13:39:12 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id DBAB4200CF for ; Mon, 14 Apr 2014 13:39:11 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1WZh4B-0006kD-2D; Mon, 14 Apr 2014 13:36:55 +0000 Received: from metis.ext.pengutronix.de ([2001:6f8:1178:4:290:27ff:fe1d:cc33]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1WZh3v-0006dx-WC for linux-arm-kernel@lists.infradead.org; Mon, 14 Apr 2014 13:36:41 +0000 Received: from dude.hi.pengutronix.de ([2001:6f8:1178:2:a236:9fff:fe00:814]) by metis.ext.pengutronix.de with esmtp (Exim 4.72) (envelope-from ) id 1WZh3G-0003Wl-85; Mon, 14 Apr 2014 15:35:58 +0200 Received: from mpa by dude.hi.pengutronix.de with local (Exim 4.82) (envelope-from ) id 1WZh3C-00081O-Rf; Mon, 14 Apr 2014 15:35:54 +0200 From: Markus Pargmann To: Mark Brown Subject: [PATCH v3 08/18] ASoC: fsl-ssi: introduce SoC specific data Date: Mon, 14 Apr 2014 15:35:38 +0200 Message-Id: <1397482548-28463-9-git-send-email-mpa@pengutronix.de> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1397482548-28463-1-git-send-email-mpa@pengutronix.de> References: <1397482548-28463-1-git-send-email-mpa@pengutronix.de> X-SA-Exim-Connect-IP: 2001:6f8:1178:2:a236:9fff:fe00:814 X-SA-Exim-Mail-From: mpa@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140414_063640_552512_5F0CD87B X-CRM114-Status: GOOD ( 24.12 ) X-Spam-Score: -1.0 (-) Cc: Fabio Estevam , alsa-devel@alsa-project.org, Alexander Shiyan , Sascha Hauer , Timur Tabi , "Li.Xiubo@freescale.com" , kernel@pengutronix.de, Nicolin Chen , linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-2.9 required=5.0 tests=BAYES_00,RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Sascha Hauer Introduce a SoC data struct which contains the differences between the different SoCs this driver supports. This makes it easy to support more differences without having to introduce a new switch/case each time. Signed-off-by: Sascha Hauer --- sound/soc/fsl/fsl_ssi.c | 125 ++++++++++++++++++++++-------------------------- 1 file changed, 57 insertions(+), 68 deletions(-) diff --git a/sound/soc/fsl/fsl_ssi.c b/sound/soc/fsl/fsl_ssi.c index 794f25f..f2255cb 100644 --- a/sound/soc/fsl/fsl_ssi.c +++ b/sound/soc/fsl/fsl_ssi.c @@ -132,6 +132,12 @@ struct fsl_ssi_rxtx_reg_val { struct fsl_ssi_reg_val tx; }; +struct fsl_ssi_soc_data { + bool imx; + bool offline_config; + u32 sisr_write_mask; +}; + /** * fsl_ssi_private: per-SSI private data * @@ -153,7 +159,6 @@ struct fsl_ssi_private { struct platform_device *pdev; unsigned int dai_fmt; - enum fsl_ssi_type hw_type; bool use_dma; bool baudclk_locked; bool use_dual_fifo; @@ -168,35 +173,9 @@ struct fsl_ssi_private { struct fsl_ssi_rxtx_reg_val rxtx_reg_val; struct fsl_ssi_dbg dbg_stats; -}; -static const struct of_device_id fsl_ssi_ids[] = { - { .compatible = "fsl,mpc8610-ssi", .data = (void *) FSL_SSI_MCP8610}, - { .compatible = "fsl,imx51-ssi", .data = (void *) FSL_SSI_MX51}, - { .compatible = "fsl,imx35-ssi", .data = (void *) FSL_SSI_MX35}, - { .compatible = "fsl,imx21-ssi", .data = (void *) FSL_SSI_MX21}, - {} + const struct fsl_ssi_soc_data *soc; }; -MODULE_DEVICE_TABLE(of, fsl_ssi_ids); - -static bool fsl_ssi_is_ac97(struct fsl_ssi_private *ssi_private) -{ - return !!(ssi_private->dai_fmt & SND_SOC_DAIFMT_AC97); -} - -static bool fsl_ssi_on_imx(struct fsl_ssi_private *ssi_private) -{ - switch (ssi_private->hw_type) { - case FSL_SSI_MX21: - case FSL_SSI_MX35: - case FSL_SSI_MX51: - return true; - case FSL_SSI_MCP8610: - return false; - } - - return false; -} /* * imx51 and later SoCs have a slightly different IP that allows the @@ -213,18 +192,48 @@ static bool fsl_ssi_on_imx(struct fsl_ssi_private *ssi_private) * while the SSI unit is running (SSIEN). So we support the necessary * online configuration of fsl-ssi starting at imx51. */ -static bool fsl_ssi_offline_config(struct fsl_ssi_private *ssi_private) -{ - switch (ssi_private->hw_type) { - case FSL_SSI_MCP8610: - case FSL_SSI_MX21: - case FSL_SSI_MX35: - return true; - case FSL_SSI_MX51: - return false; - } - return true; +static struct fsl_ssi_soc_data fsl_ssi_mpc8610 = { + .imx = false, + .offline_config = true, + .sisr_write_mask = CCSR_SSI_SISR_RFRC | CCSR_SSI_SISR_TFRC | + CCSR_SSI_SISR_ROE0 | CCSR_SSI_SISR_ROE1 | + CCSR_SSI_SISR_TUE0 | CCSR_SSI_SISR_TUE1, +}; + +static struct fsl_ssi_soc_data fsl_ssi_imx21 = { + .imx = true, + .offline_config = true, + .sisr_write_mask = 0, +}; + +static struct fsl_ssi_soc_data fsl_ssi_imx35 = { + .imx = true, + .offline_config = true, + .sisr_write_mask = CCSR_SSI_SISR_RFRC | CCSR_SSI_SISR_TFRC | + CCSR_SSI_SISR_ROE0 | CCSR_SSI_SISR_ROE1 | + CCSR_SSI_SISR_TUE0 | CCSR_SSI_SISR_TUE1, +}; + +static struct fsl_ssi_soc_data fsl_ssi_imx51 = { + .imx = true, + .offline_config = false, + .sisr_write_mask = CCSR_SSI_SISR_ROE0 | CCSR_SSI_SISR_ROE1 | + CCSR_SSI_SISR_TUE0 | CCSR_SSI_SISR_TUE1, +}; + +static const struct of_device_id fsl_ssi_ids[] = { + { .compatible = "fsl,mpc8610-ssi", .data = &fsl_ssi_mpc8610 }, + { .compatible = "fsl,imx51-ssi", .data = &fsl_ssi_imx51 }, + { .compatible = "fsl,imx35-ssi", .data = &fsl_ssi_imx35 }, + { .compatible = "fsl,imx21-ssi", .data = &fsl_ssi_imx21 }, + {} +}; +MODULE_DEVICE_TABLE(of, fsl_ssi_ids); + +static bool fsl_ssi_is_ac97(struct fsl_ssi_private *ssi_private) +{ + return !!(ssi_private->dai_fmt & SND_SOC_DAIFMT_AC97); } /** @@ -245,25 +254,6 @@ static irqreturn_t fsl_ssi_isr(int irq, void *dev_id) struct ccsr_ssi __iomem *ssi = ssi_private->ssi; __be32 sisr; __be32 sisr2; - __be32 sisr_write_mask = 0; - - switch (ssi_private->hw_type) { - case FSL_SSI_MX21: - sisr_write_mask = 0; - break; - - case FSL_SSI_MCP8610: - case FSL_SSI_MX35: - sisr_write_mask = CCSR_SSI_SISR_RFRC | CCSR_SSI_SISR_TFRC | - CCSR_SSI_SISR_ROE0 | CCSR_SSI_SISR_ROE1 | - CCSR_SSI_SISR_TUE0 | CCSR_SSI_SISR_TUE1; - break; - - case FSL_SSI_MX51: - sisr_write_mask = CCSR_SSI_SISR_ROE0 | CCSR_SSI_SISR_ROE1 | - CCSR_SSI_SISR_TUE0 | CCSR_SSI_SISR_TUE1; - break; - } /* We got an interrupt, so read the status register to see what we were interrupted for. We mask it with the Interrupt Enable register @@ -271,7 +261,7 @@ static irqreturn_t fsl_ssi_isr(int irq, void *dev_id) */ sisr = read_ssi(&ssi->sisr); - sisr2 = sisr & sisr_write_mask; + sisr2 = sisr & ssi_private->soc->sisr_write_mask; /* Clear the bits that we set */ if (sisr2) write_ssi(sisr2, &ssi->sisr); @@ -359,7 +349,7 @@ static void fsl_ssi_config(struct fsl_ssi_private *ssi_private, bool enable, * reconfiguration, so we have to enable all necessary flags at once * even if we do not use them later (capture and playback configuration) */ - if (fsl_ssi_offline_config(ssi_private)) { + if (ssi_private->soc->offline_config) { if ((enable && !nr_active_streams) || (!enable && !keep_active)) fsl_ssi_rxtx_config(ssi_private, enable); @@ -910,7 +900,7 @@ static int fsl_ssi_dai_probe(struct snd_soc_dai *dai) { struct fsl_ssi_private *ssi_private = snd_soc_dai_get_drvdata(dai); - if (fsl_ssi_on_imx(ssi_private) && ssi_private->use_dma) { + if (ssi_private->soc->imx && ssi_private->use_dma) { dai->playback_dma_data = &ssi_private->dma_params_tx; dai->capture_dma_data = &ssi_private->dma_params_rx; } @@ -1136,7 +1126,6 @@ static int fsl_ssi_probe(struct platform_device *pdev) int ret = 0; struct device_node *np = pdev->dev.of_node; const struct of_device_id *of_id; - enum fsl_ssi_type hw_type; const char *p, *sprop; const uint32_t *iprop; struct resource res; @@ -1151,9 +1140,8 @@ static int fsl_ssi_probe(struct platform_device *pdev) return -ENODEV; of_id = of_match_device(fsl_ssi_ids, &pdev->dev); - if (!of_id) + if (!of_id || !of_id->data) return -EINVAL; - hw_type = (enum fsl_ssi_type) of_id->data; sprop = of_get_property(np, "fsl,mode", NULL); if (!sprop) { @@ -1170,9 +1158,10 @@ static int fsl_ssi_probe(struct platform_device *pdev) return -ENOMEM; } + ssi_private->soc = of_id->data; + ssi_private->use_dma = !of_property_read_bool(np, "fsl,fiq-stream-filter"); - ssi_private->hw_type = hw_type; if (ac97) { memcpy(&ssi_private->cpu_dai_drv, &fsl_ssi_ac97_dai, @@ -1227,7 +1216,7 @@ static int fsl_ssi_probe(struct platform_device *pdev) dev_set_drvdata(&pdev->dev, ssi_private); - if (fsl_ssi_on_imx(ssi_private)) { + if (ssi_private->soc->imx) { ret = fsl_ssi_imx_probe(pdev, ssi_private, ssi_private->ssi); if (ret) goto error_irqmap; @@ -1294,7 +1283,7 @@ error_irq: snd_soc_unregister_component(&pdev->dev); error_asoc_register: - if (fsl_ssi_on_imx(ssi_private)) + if (ssi_private->soc->imx) fsl_ssi_imx_clean(pdev, ssi_private); error_irqmap: @@ -1314,7 +1303,7 @@ static int fsl_ssi_remove(struct platform_device *pdev) platform_device_unregister(ssi_private->pdev); snd_soc_unregister_component(&pdev->dev); - if (fsl_ssi_on_imx(ssi_private)) + if (ssi_private->soc->imx) fsl_ssi_imx_clean(pdev, ssi_private); if (ssi_private->use_dma)