Commit c511595390a373e19a774246c659b4f563a4c3f3

Authored by Nicolas Ferre
Committed by Vinod Koul
1 parent 67348450b8

dmaengine: at_hdmac: add device tree support

Add device tree probe support for atmel at_hdmac DMA driver.
Bindings are added to specify DMA controller configuration.

Signed-off-by: Nicolas Ferre <nicolas.ferre@atmel.com>
Acked-by: Grant Likely <grant.likely@secretlab.ca>
Signed-off-by: Vinod Koul <vinod.koul@linux.intel.com>

Showing 2 changed files with 45 additions and 1 deletions Side-by-side Diff

Documentation/devicetree/bindings/dma/atmel-dma.txt
  1 +* Atmel Direct Memory Access Controller (DMA)
  2 +
  3 +Required properties:
  4 +- compatible: Should be "atmel,<chip>-dma"
  5 +- reg: Should contain DMA registers location and length
  6 +- interrupts: Should contain DMA interrupt
  7 +
  8 +Examples:
  9 +
  10 +dma@ffffec00 {
  11 + compatible = "atmel,at91sam9g45-dma";
  12 + reg = <0xffffec00 0x200>;
  13 + interrupts = <21>;
  14 +};
drivers/dma/at_hdmac.c
... ... @@ -23,6 +23,8 @@
23 23 #include <linux/module.h>
24 24 #include <linux/platform_device.h>
25 25 #include <linux/slab.h>
  26 +#include <linux/of.h>
  27 +#include <linux/of_device.h>
26 28  
27 29 #include "at_hdmac_regs.h"
28 30  
... ... @@ -1175,6 +1177,20 @@
1175 1177  
1176 1178 /*-- Module Management -----------------------------------------------*/
1177 1179  
  1180 +#if defined(CONFIG_OF)
  1181 +static const struct of_device_id atmel_dma_dt_ids[] = {
  1182 + {
  1183 + .compatible = "atmel,at91sam9rl-dma",
  1184 + .data = (void *)ATDMA_DEVTYPE_SAM9RL
  1185 + }, {
  1186 + .compatible = "atmel,at91sam9g45-dma",
  1187 + .data = (void *)ATDMA_DEVTYPE_SAM9G45
  1188 + }, { /* sentinel */ }
  1189 +};
  1190 +
  1191 +MODULE_DEVICE_TABLE(of, atmel_dma_dt_ids);
  1192 +#endif
  1193 +
1178 1194 static struct platform_device_id atdma_devtypes[] = {
1179 1195 {
1180 1196 .name = "at91sam9rl_dma",
... ... @@ -1187,6 +1203,19 @@
1187 1203 }
1188 1204 };
1189 1205  
  1206 +static inline enum atdma_devtype __init at_dma_get_driver_data(
  1207 + struct platform_device *pdev)
  1208 +{
  1209 + if (pdev->dev.of_node) {
  1210 + const struct of_device_id *match;
  1211 + match = of_match_node(atmel_dma_dt_ids, pdev->dev.of_node);
  1212 + if (match == NULL)
  1213 + return ATDMA_DEVTYPE_UNDEFINED;
  1214 + return (enum atdma_devtype)match->data;
  1215 + }
  1216 + return platform_get_device_id(pdev)->driver_data;
  1217 +}
  1218 +
1190 1219 /**
1191 1220 * at_dma_off - disable DMA controller
1192 1221 * @atdma: the Atmel HDAMC device
... ... @@ -1218,7 +1247,7 @@
1218 1247 dma_cap_set(DMA_MEMCPY, cap_mask);
1219 1248  
1220 1249 /* get DMA parameters from controller type */
1221   - atdmatype = platform_get_device_id(pdev)->driver_data;
  1250 + atdmatype = at_dma_get_driver_data(pdev);
1222 1251  
1223 1252 switch (atdmatype) {
1224 1253 case ATDMA_DEVTYPE_SAM9RL:
... ... @@ -1526,6 +1555,7 @@
1526 1555 .driver = {
1527 1556 .name = "at_hdmac",
1528 1557 .pm = &at_dma_dev_pm_ops,
  1558 + .of_match_table = of_match_ptr(atmel_dma_dt_ids),
1529 1559 },
1530 1560 };
1531 1561