From patchwork Sun Mar 10 18:33:11 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markus Pargmann X-Patchwork-Id: 226469 Return-Path: X-Original-To: incoming-imx@patchwork.ozlabs.org Delivered-To: patchwork-incoming-imx@bilbo.ozlabs.org Received: from merlin.infradead.org (merlin.infradead.org [IPv6:2001:4978:20e::2]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 4481A2C02B7 for ; Mon, 11 Mar 2013 05:39:39 +1100 (EST) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1UEl5s-00050n-TI; Sun, 10 Mar 2013 18:35:37 +0000 Received: from metis.ext.pengutronix.de ([2001:6f8:1178:4:290:27ff:fe1d:cc33]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1UEl5D-0004pd-NR for linux-arm-kernel@lists.infradead.org; Sun, 10 Mar 2013 18:34:58 +0000 Received: from dude.hi.pengutronix.de ([2001:6f8:1178:2:21e:67ff:fe11:9c5c]) by metis.ext.pengutronix.de with esmtp (Exim 4.72) (envelope-from ) id 1UEl5A-0005G6-4E; Sun, 10 Mar 2013 19:34:52 +0100 Received: from mpa by dude.hi.pengutronix.de with local (Exim 4.80) (envelope-from ) id 1UEl4v-0002uz-Um; Sun, 10 Mar 2013 19:34:37 +0100 From: Markus Pargmann To: linux-arm-kernel@lists.infradead.org Subject: [PATCH 10/10] ASoC: imx-ssi: Add imx27 and pca100 DT support Date: Sun, 10 Mar 2013 19:33:11 +0100 Message-Id: <1362940391-8338-11-git-send-email-mpa@pengutronix.de> X-Mailer: git-send-email 1.8.2.rc2 In-Reply-To: <1362940391-8338-1-git-send-email-mpa@pengutronix.de> References: <1362940391-8338-1-git-send-email-mpa@pengutronix.de> X-SA-Exim-Connect-IP: 2001:6f8:1178:2:21e:67ff:fe11:9c5c 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-20130310_143456_232891_F09D3AE7 X-CRM114-Status: GOOD ( 23.17 ) X-Spam-Score: -4.3 (----) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-4.3 points) pts rule name description ---- ---------------------- -------------------------------------------------- -2.4 RP_MATCHES_RCVD Envelope sender domain matches handover relay domain -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Cc: Fabio Estevam , alsa-devel@alsa-project.org, devicetree-discuss@lists.ozlabs.org, Mark Brown , Liam Girdwood , Grant Likely , Sascha Hauer , Markus Pargmann , Shawn Guo , Timur Tabi X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+incoming-imx=patchwork.ozlabs.org@lists.infradead.org List-Id: linux-imx-kernel.lists.patchwork.ozlabs.org Add devicetree bindings for generic imx-ssi support and specifically for pca100 with two custom reset functions. At the moment those functions are defined in mach-pca100.c. So until DT is the only method for booting, the ac97 reset functions have to be exported in mach-pca100.c. Signed-off-by: Markus Pargmann --- .../devicetree/bindings/sound/fsl-imx-ssi | 34 +++++++++ arch/arm/mach-imx/mach-pca100.c | 7 +- sound/soc/fsl/imx-ssi.c | 85 +++++++++++++++++++--- 3 files changed, 115 insertions(+), 11 deletions(-) create mode 100644 Documentation/devicetree/bindings/sound/fsl-imx-ssi diff --git a/Documentation/devicetree/bindings/sound/fsl-imx-ssi b/Documentation/devicetree/bindings/sound/fsl-imx-ssi new file mode 100644 index 0000000..853afeb --- /dev/null +++ b/Documentation/devicetree/bindings/sound/fsl-imx-ssi @@ -0,0 +1,34 @@ +Freescale imx ssi driver + +Required properties: +- compatible : "fsl,imx27-ssi" or "phytec,imx27-pca100-ssi" +- reg : Should contain registers location and length +- interrupts : Should be the ssi interrupt +- clocks : Define at least one clock to be used. + +Optional properties: +- dmas : DMA client request phandle list with arguements as defined by the DMA + controller used. See generic DMA devicetree bindings for more information. +- dma-names : Names of the defined DMA client requests. "rx0" and "tx0" have to + be defined. +- imx-ssi-ac97 : Use AC97 +- imx-ssi-i2s-slave : Use I2S slave +- imx-ssi-net +- imx-ssi-syn + + +Example: +ssi1: ssi@10010000 { + compatible = "fsl,imx27-ssi"; + reg = <0x10010000 0x1000>; + interrupts = <14>; + dmas = <&dma 8 + &dma 9 + &dma 10 + &dma 11>; + dma-names = "rx0", "tx0", "rx1", "tx1"; + clocks = <&clks 25>; + clock-names = "ipg"; + imx-ssi-ac97; + status = "disabled"; +}; diff --git a/arch/arm/mach-imx/mach-pca100.c b/arch/arm/mach-imx/mach-pca100.c index b8b15bb..0d54921 100644 --- a/arch/arm/mach-imx/mach-pca100.c +++ b/arch/arm/mach-imx/mach-pca100.c @@ -25,6 +25,7 @@ #include #include #include +#include #include #include #include @@ -208,7 +209,7 @@ static const struct spi_imx_master pca100_spi0_data __initconst = { .num_chipselect = ARRAY_SIZE(pca100_spi_cs), }; -static void pca100_ac97_warm_reset(struct snd_ac97 *ac97) +void pca100_ac97_warm_reset(struct snd_ac97 *ac97) { mxc_gpio_mode(GPIO_PORTC | 20 | GPIO_GPIO | GPIO_OUT); gpio_set_value(GPIO_PORTC + 20, 1); @@ -217,8 +218,9 @@ static void pca100_ac97_warm_reset(struct snd_ac97 *ac97) mxc_gpio_mode(PC20_PF_SSI1_FS); msleep(2); } +EXPORT_SYMBOL(pca100_ac97_warm_reset); -static void pca100_ac97_cold_reset(struct snd_ac97 *ac97) +void pca100_ac97_cold_reset(struct snd_ac97 *ac97) { mxc_gpio_mode(GPIO_PORTC | 20 | GPIO_GPIO | GPIO_OUT); /* FS */ gpio_set_value(GPIO_PORTC + 20, 0); @@ -232,6 +234,7 @@ static void pca100_ac97_cold_reset(struct snd_ac97 *ac97) mxc_gpio_mode(PC22_PF_SSI1_TXD); msleep(2); } +EXPORT_SYMBOL(pca100_ac97_cold_reset); static const struct imx_ssi_platform_data pca100_ssi_pdata __initconst = { .ac97_reset = pca100_ac97_cold_reset, diff --git a/sound/soc/fsl/imx-ssi.c b/sound/soc/fsl/imx-ssi.c index 96e24a3..58de760 100644 --- a/sound/soc/fsl/imx-ssi.c +++ b/sound/soc/fsl/imx-ssi.c @@ -38,6 +38,7 @@ #include #include #include +#include #include #include @@ -53,6 +54,46 @@ #define SSI_SACNT_DEFAULT (SSI_SACNT_AC97EN | SSI_SACNT_FV) +#ifdef CONFIG_MACH_PCA100 +extern void pca100_ac97_cold_reset(struct snd_ac97 *ac97); +extern void pca100_ac97_warm_reset(struct snd_ac97 *ac97); +#else +void pca100_ac97_cold_reset(struct snd_ac97 *ac97) { } +void pca100_ac97_warm_reset(struct snd_ac97 *ac97) { } +#endif + + +enum imx_ssi_type { + IMX27_SSI = 0, + IMX27_PCA100_SSI, +}; + +static const struct imx_ssi_platform_data imx_ssi_devtype[] = { + { + .ac97_reset = NULL, + .ac97_warm_reset = NULL, + }, + { + .ac97_reset = pca100_ac97_cold_reset, + .ac97_warm_reset = pca100_ac97_warm_reset, + }, { + /* sentinel */ + } +}; + +static const struct of_device_id imx_ssi_of_dev_id[] = { + { + .compatible = "fsl,imx27-ssi", + .data = &imx_ssi_devtype[IMX27_SSI], + }, { + .compatible = "phytec,imx27-pca100-ssi", + .data = &imx_ssi_devtype[IMX27_PCA100_SSI], + }, { + /* sentinel */ + } +}; +MODULE_DEVICE_TABLE(of, imx_ssi_of_dev_id); + /* * SSI Network Mode or TDM slots configuration. * Should only be called when port is inactive (i.e. SSIEN = 0). @@ -528,9 +569,12 @@ static int imx_ssi_probe(struct platform_device *pdev) { struct resource *res; struct imx_ssi *ssi; - struct imx_ssi_platform_data *pdata = pdev->dev.platform_data; + const struct imx_ssi_platform_data *pdata = pdev->dev.platform_data; int ret = 0; struct snd_soc_dai_driver *dai; + const struct of_device_id *of_id; + + of_id = of_match_device(imx_ssi_of_dev_id, &pdev->dev); ssi = devm_kzalloc(&pdev->dev, sizeof(*ssi), GFP_KERNEL); if (!ssi) @@ -538,10 +582,25 @@ static int imx_ssi_probe(struct platform_device *pdev) dev_set_drvdata(&pdev->dev, ssi); if (pdata) { - ssi->ac97_reset = pdata->ac97_reset; - ssi->ac97_warm_reset = pdata->ac97_warm_reset; ssi->flags = pdata->flags; + } else { + pdata = of_id->data; + ssi->flags = 0; + + if (of_property_read_bool(pdev->dev.of_node, "dmas")) + ssi->flags |= IMX_SSI_DMA; + if (of_property_read_bool(pdev->dev.of_node, "imx-ssi-ac97")) + ssi->flags |= IMX_SSI_USE_AC97; + if (of_property_read_bool(pdev->dev.of_node, "imx-ssi-net")) + ssi->flags |= IMX_SSI_NET; + if (of_property_read_bool(pdev->dev.of_node, "imx-ssi-syn")) + ssi->flags |= IMX_SSI_SYN; + if (of_property_read_bool(pdev->dev.of_node, + "imx-ssi-i2s-slave")) + ssi->flags |= IMX_SSI_USE_I2S_SLAVE; } + ssi->ac97_reset = pdata->ac97_reset; + ssi->ac97_warm_reset = pdata->ac97_warm_reset; ssi->irq = platform_get_irq(pdev, 0); @@ -586,13 +645,20 @@ static int imx_ssi_probe(struct platform_device *pdev) ssi->dma_params_tx.burstsize = 6; ssi->dma_params_rx.burstsize = 4; - res = platform_get_resource_byname(pdev, IORESOURCE_DMA, "tx0"); - if (res) - ssi->dma_params_tx.dma = res->start; + if (pdev->dev.platform_data) { + res = platform_get_resource_byname(pdev, IORESOURCE_DMA, "tx0"); + if (res) + ssi->dma_params_tx.dma = res->start; - res = platform_get_resource_byname(pdev, IORESOURCE_DMA, "rx0"); - if (res) - ssi->dma_params_rx.dma = res->start; + res = platform_get_resource_byname(pdev, IORESOURCE_DMA, "rx0"); + if (res) + ssi->dma_params_rx.dma = res->start; + } else { + ssi->dma_params_rx.dma_client_node = pdev->dev.of_node; + ssi->dma_params_rx.dma_req_name = "rx0"; + ssi->dma_params_tx.dma_client_node = pdev->dev.of_node; + ssi->dma_params_tx.dma_req_name = "tx0"; + } platform_set_drvdata(pdev, ssi); @@ -673,6 +739,7 @@ static struct platform_driver imx_ssi_driver = { .driver = { .name = "imx-ssi", .owner = THIS_MODULE, + .of_match_table = imx_ssi_of_dev_id, }, };