From patchwork Fri Jul 15 09:44:26 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shawn Guo X-Patchwork-Id: 2712 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 0F99323F44 for ; Fri, 15 Jul 2011 09:33:07 +0000 (UTC) Received: from mail-qw0-f52.google.com (mail-qw0-f52.google.com [209.85.216.52]) by fiordland.canonical.com (Postfix) with ESMTP id D443FA186AE for ; Fri, 15 Jul 2011 09:33:06 +0000 (UTC) Received: by mail-qw0-f52.google.com with SMTP id 8so734711qwb.11 for ; Fri, 15 Jul 2011 02:33:06 -0700 (PDT) Received: by 10.229.217.3 with SMTP id hk3mr2777722qcb.38.1310722386623; Fri, 15 Jul 2011 02:33:06 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.229.217.78 with SMTP id hl14cs42232qcb; Fri, 15 Jul 2011 02:33:06 -0700 (PDT) Received: by 10.42.172.198 with SMTP id o6mr3753474icz.50.1310722386094; Fri, 15 Jul 2011 02:33:06 -0700 (PDT) Received: from mail-iw0-f178.google.com (mail-iw0-f178.google.com [209.85.214.178]) by mx.google.com with ESMTPS id p3si3188586icc.102.2011.07.15.02.33.05 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 15 Jul 2011 02:33:06 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.214.178 is neither permitted nor denied by best guess record for domain of shawn.guo@linaro.org) client-ip=209.85.214.178; Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.214.178 is neither permitted nor denied by best guess record for domain of shawn.guo@linaro.org) smtp.mail=shawn.guo@linaro.org Received: by mail-iw0-f178.google.com with SMTP id 10so1091500iwc.37 for ; Fri, 15 Jul 2011 02:33:05 -0700 (PDT) Received: by 10.42.189.67 with SMTP id dd3mr3489514icb.268.1310722385192; Fri, 15 Jul 2011 02:33:05 -0700 (PDT) Received: from localhost.localdomain ([121.236.240.37]) by mx.google.com with ESMTPS id hq1sm1196559icc.2.2011.07.15.02.32.57 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 15 Jul 2011 02:33:04 -0700 (PDT) From: Shawn Guo To: linux-arm-kernel@lists.infradead.org Cc: devicetree-discuss@lists.ozlabs.org, patches@linaro.org, Shawn Guo , Grant Likely , Vinod Koul , Sascha Hauer Subject: [PATCH v2 3/3] dmaengine: imx-sdma: add device tree probe support Date: Fri, 15 Jul 2011 17:44:26 +0800 Message-Id: <1310723066-567-4-git-send-email-shawn.guo@linaro.org> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1310723066-567-1-git-send-email-shawn.guo@linaro.org> References: <1310723066-567-1-git-send-email-shawn.guo@linaro.org> 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 | 17 ++++++++ drivers/dma/imx-sdma.c | 41 ++++++++++++++++++- 2 files changed, 55 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..d1e3f44 --- /dev/null +++ b/Documentation/devicetree/bindings/dma/fsl-imx-sdma.txt @@ -0,0 +1,17 @@ +* 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-ram-script-name : Should contain the full path of SDMA RAM + scripts firmware + +Examples: + +sdma@83fb0000 { + compatible = "fsl,imx51-sdma", "fsl,imx35-sdma"; + reg = <0x83fb0000 0x4000>; + interrupts = <6>; + fsl,sdma-ram-script-name = "sdma-imx51.bin"; +}; diff --git a/drivers/dma/imx-sdma.c b/drivers/dma/imx-sdma.c index 6b839a2..20504f0 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 */ @@ -1249,6 +1257,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; @@ -1264,7 +1276,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; } @@ -1294,6 +1306,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); @@ -1324,10 +1338,30 @@ static int __init sdma_probe(struct platform_device *pdev) if (ret) goto err_init; - if (pdata->script_addrs) + if (pdata && pdata->script_addrs) sdma_add_scripts(sdma, pdata->script_addrs); - sdma_get_firmware(sdma, pdata->fw_name); + if (pdata) { + sdma_get_firmware(sdma, pdata->fw_name); + } else { + /* + * Because that device tree does not encode ROM script address, + * the RAM script in firmware is mandatory for device tree + * probe, otherwise it fails. + */ + ret = of_property_read_string(np, "fsl,sdma-ram-script-name", + &fw_name); + if (ret) { + dev_err(&pdev->dev, "failed to get firmware name\n"); + goto err_init; + } + + ret = sdma_get_firmware(sdma, fw_name); + if (ret) { + dev_err(&pdev->dev, "failed to get firmware\n"); + goto err_init; + } + } sdma->dma_device.dev = &pdev->dev; @@ -1375,6 +1409,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),