|
@@ -32,6 +32,8 @@
|
|
|
#include <linux/slab.h>
|
|
|
#include <linux/platform_device.h>
|
|
|
#include <linux/dmaengine.h>
|
|
|
+#include <linux/of.h>
|
|
|
+#include <linux/of_device.h>
|
|
|
|
|
|
#include <asm/irq.h>
|
|
|
#include <mach/sdma.h>
|
|
@@ -332,6 +334,13 @@ static struct platform_device_id sdma_devtypes[] = {
|
|
|
};
|
|
|
MODULE_DEVICE_TABLE(platform, 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 */ }
|
|
|
+};
|
|
|
+MODULE_DEVICE_TABLE(of, sdma_dt_ids);
|
|
|
+
|
|
|
#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 */
|
|
@@ -1250,6 +1259,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;
|
|
@@ -1265,7 +1278,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;
|
|
|
}
|
|
@@ -1295,6 +1308,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);
|
|
@@ -1325,10 +1340,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;
|
|
|
|
|
@@ -1376,6 +1411,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),
|