From patchwork Thu Jul 14 16:14:17 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shawn Guo X-Patchwork-Id: 975282 Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by demeter1.kernel.org (8.14.4/8.14.4) with ESMTP id p6EG45wh011278 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Thu, 14 Jul 2011 16:04:26 GMT Received: from canuck.infradead.org ([2001:4978:20e::1]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1QhOO7-0006KM-1Z; Thu, 14 Jul 2011 16:03:43 +0000 Received: from localhost ([127.0.0.1] helo=canuck.infradead.org) by canuck.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1QhOO6-0000eO-46; Thu, 14 Jul 2011 16:03:42 +0000 Received: from mail-iw0-f177.google.com ([209.85.214.177]) by canuck.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1QhOO0-0000ct-5x for linux-arm-kernel@lists.infradead.org; Thu, 14 Jul 2011 16:03:40 +0000 Received: by iwn35 with SMTP id 35so379568iwn.36 for ; Thu, 14 Jul 2011 09:03:34 -0700 (PDT) Received: by 10.42.144.65 with SMTP id a1mr2206638icv.456.1310659413819; Thu, 14 Jul 2011 09:03:33 -0700 (PDT) Received: from localhost.localdomain ([117.82.20.93]) by mx.google.com with ESMTPS id o10sm408460icc.12.2011.07.14.09.03.10 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 14 Jul 2011 09:03:33 -0700 (PDT) From: Shawn Guo To: linux-arm-kernel@lists.infradead.org Subject: [PATCH 2/2] dmaengine: imx-sdma: add device tree probe support Date: Fri, 15 Jul 2011 00:14:17 +0800 Message-Id: <1310660057-17953-3-git-send-email-shawn.guo@linaro.org> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1310660057-17953-1-git-send-email-shawn.guo@linaro.org> References: <1310660057-17953-1-git-send-email-shawn.guo@linaro.org> X-CRM114-Version: 20090807-BlameThorstenAndJenny ( TRE 0.7.6 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20110714_120336_543323_491C6E9F X-CRM114-Status: GOOD ( 19.32 ) X-Spam-Score: -0.7 (/) X-Spam-Report: SpamAssassin version 3.3.1 on canuck.infradead.org summary: Content analysis details: (-0.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [209.85.214.177 listed in list.dnswl.org] Cc: patches@linaro.org, Vinod Koul , devicetree-discuss@lists.ozlabs.org, Grant Likely , Shawn Guo , Sascha Hauer X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: linux-arm-kernel-bounces@lists.infradead.org Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Thu, 14 Jul 2011 16:04:26 +0000 (UTC) It adds device tree probe support for imx-sdma driver. Signed-off-by: Shawn Guo Cc: Grant Likely Cc: Vinod Koul Cc: Sascha Hauer --- .../devicetree/bindings/dma/fsl-imx-sdma.txt | 55 ++++++++++++++++++++ drivers/dma/imx-sdma.c | 29 +++++++++- 2 files changed, 81 insertions(+), 3 deletions(-) create mode 100644 Documentation/devicetree/bindings/dma/fsl-imx-sdma.txt diff --git a/Documentation/devicetree/bindings/dma/fsl-imx-sdma.txt b/Documentation/devicetree/bindings/dma/fsl-imx-sdma.txt new file mode 100644 index 0000000..71f4525 --- /dev/null +++ b/Documentation/devicetree/bindings/dma/fsl-imx-sdma.txt @@ -0,0 +1,55 @@ +* Freescale Smart Direct Memory Access (SDMA) Controller for i.MX + +Required properties: +- compatible : Should be "fsl,-sdma" +- reg : Should contain SDMA registers location and length +- interrupts : Should contain SDMA interrupt +- fsl,sdma-script-name : Should contain the full path of SDMA RAM scripts + firmware +- fsl,sdma-script-address : Should be an array giving entry address for each + script. The address should be 0 in case that the specified script is not + included in the firmware. See example below for the array details. + +Examples: + +sdma@83fb0000 { + compatible = "fsl,imx51-sdma", "fsl,imx35-sdma"; + reg = <0x83fb0000 0x4000>; + interrupts = <6>; + fsl,sdma-script-name = "sdma-imx51.bin"; + fsl,sdma-script-address = <642>, /* ap_2_ap */ + <0>, /* ap_2_bp */ + <0>, /* ap_2_ap_fixed */ + <0>, /* bp_2_ap */ + <0>, /* loopback_on_dsp_side */ + <0>, /* mcu_interrupt_only */ + <0>, /* firi_2_per */ + <0>, /* firi_2_mcu */ + <0>, /* per_2_firi */ + <0>, /* mcu_2_firi */ + <0>, /* uart_2_per */ + <817>, /* uart_2_mcu */ + <0>, /* per_2_app */ + <747>, /* mcu_2_app */ + <0>, /* per_2_per */ + <0>, /* uartsh_2_per */ + <0>, /* uartsh_2_mcu */ + <0>, /* per_2_shp */ + <961>, /* mcu_2_shp */ + <1473>, /* ata_2_mcu */ + <1392>, /* mcu_2_ata */ + <1033>, /* app_2_per */ + <683>, /* app_2_mcu */ + <1251>, /* shp_2_per */ + <892>, /* shp_2_mcu */ + <0>, /* mshc_2_mcu */ + <0>, /* mcu_2_mshc */ + <0>, /* spdif_2_mcu */ + <0>, /* mcu_2_spdif */ + <0>, /* asrc_2_mcu */ + <0>, /* ext_mem_2_ipu */ + <0>, /* descrambler */ + <0>, /* dptc_dvfs */ + <0>, /* utra_addr */ + <0>; /* ram_code_start */ +}; diff --git a/drivers/dma/imx-sdma.c b/drivers/dma/imx-sdma.c index 4a7aa72..664f7bc 100644 --- a/drivers/dma/imx-sdma.c +++ b/drivers/dma/imx-sdma.c @@ -32,6 +32,8 @@ #include #include #include +#include +#include #include #include @@ -331,6 +333,12 @@ static struct platform_device_id sdma_devtypes[] = { } }; +static const struct of_device_id sdma_dt_ids[] = { + { .compatible = "fsl,imx31-sdma", .data = &sdma_devtypes[IMX31_SDMA], }, + { .compatible = "fsl,imx35-sdma", .data = &sdma_devtypes[IMX35_SDMA], }, + { /* sentinel */ } +}; + #define SDMA_H_CONFIG_DSPDMA (1 << 12) /* indicates if the DSPDMA is used */ #define SDMA_H_CONFIG_RTD_PINS (1 << 11) /* indicates if Real-Time Debug pins are enabled */ #define SDMA_H_CONFIG_ACR (1 << 4) /* indicates if AHB freq /core freq = 2 or 1 */ @@ -1257,6 +1265,10 @@ err_dma_alloc: static int __init sdma_probe(struct platform_device *pdev) { + const struct of_device_id *of_id = + of_match_device(sdma_dt_ids, &pdev->dev); + struct device_node *np = pdev->dev.of_node; + const char *fw_name; int ret; int irq; struct resource *iores; @@ -1272,7 +1284,7 @@ static int __init sdma_probe(struct platform_device *pdev) iores = platform_get_resource(pdev, IORESOURCE_MEM, 0); irq = platform_get_irq(pdev, 0); - if (!iores || irq < 0 || !pdata) { + if (!iores || irq < 0) { ret = -EINVAL; goto err_irq; } @@ -1302,6 +1314,8 @@ static int __init sdma_probe(struct platform_device *pdev) if (!sdma->script_addrs) goto err_alloc; + if (of_id) + pdev->id_entry = of_id->data; sdma->devtype = pdev->id_entry->driver_data; dma_cap_set(DMA_SLAVE, sdma->dma_device.cap_mask); @@ -1332,10 +1346,18 @@ static int __init sdma_probe(struct platform_device *pdev) if (ret) goto err_init; - if (pdata->script_addrs) + ret = of_property_read_u32_array(np, "fsl,sdma-script-address", + (u32 *) sdma->script_addrs, + sizeof(*sdma->script_addrs) / sizeof(u32)); + if (ret < 0 && pdata && pdata->script_addrs) sdma_add_scripts(sdma, pdata->script_addrs); - sdma_get_firmware(sdma, pdata->fw_name); + ret = of_property_read_string(np, "fsl,sdma-script-name", + &fw_name); + if (!ret) + sdma_get_firmware(sdma, fw_name); + else if (pdata) + sdma_get_firmware(sdma, pdata->fw_name); sdma->dma_device.dev = &pdev->dev; @@ -1383,6 +1405,7 @@ static int __exit sdma_remove(struct platform_device *pdev) static struct platform_driver sdma_driver = { .driver = { .name = "imx-sdma", + .of_match_table = sdma_dt_ids, }, .id_table = sdma_devtypes, .remove = __exit_p(sdma_remove),