aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorNicolas Ferre <nicolas.ferre@atmel.com>2011-10-17 08:56:40 -0400
committerVinod Koul <vinod.koul@linux.intel.com>2011-11-10 03:43:33 -0500
commit67348450b86cb1b42aa4dd55cf7cde19c2e53461 (patch)
tree85bae4e8095d9cf41f539f401d179dcc9fde35b8 /drivers
parent1ea6b8f48918282bdca0b32a34095504ee65bab5 (diff)
dmaengine: at_hdmac: platform data move to use .id_table
We remove the use of platform data from DMA controller driver. We now use of .id_table to distinguish between compatible types. The two implementations allow to determine the number of channels and the capabilities of the controller. 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>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/dma/at_hdmac.c48
-rw-r--r--drivers/dma/at_hdmac_regs.h8
2 files changed, 46 insertions, 10 deletions
diff --git a/drivers/dma/at_hdmac.c b/drivers/dma/at_hdmac.c
index fcfa0a8b5c59..d1869c597e42 100644
--- a/drivers/dma/at_hdmac.c
+++ b/drivers/dma/at_hdmac.c
@@ -1175,6 +1175,18 @@ static void atc_free_chan_resources(struct dma_chan *chan)
1175 1175
1176/*-- Module Management -----------------------------------------------*/ 1176/*-- Module Management -----------------------------------------------*/
1177 1177
1178static struct platform_device_id atdma_devtypes[] = {
1179 {
1180 .name = "at91sam9rl_dma",
1181 .driver_data = ATDMA_DEVTYPE_SAM9RL,
1182 }, {
1183 .name = "at91sam9g45_dma",
1184 .driver_data = ATDMA_DEVTYPE_SAM9G45,
1185 }, {
1186 /* sentinel */
1187 }
1188};
1189
1178/** 1190/**
1179 * at_dma_off - disable DMA controller 1191 * at_dma_off - disable DMA controller
1180 * @atdma: the Atmel HDAMC device 1192 * @atdma: the Atmel HDAMC device
@@ -1193,18 +1205,32 @@ static void at_dma_off(struct at_dma *atdma)
1193 1205
1194static int __init at_dma_probe(struct platform_device *pdev) 1206static int __init at_dma_probe(struct platform_device *pdev)
1195{ 1207{
1196 struct at_dma_platform_data *pdata;
1197 struct resource *io; 1208 struct resource *io;
1198 struct at_dma *atdma; 1209 struct at_dma *atdma;
1199 size_t size; 1210 size_t size;
1200 int irq; 1211 int irq;
1201 int err; 1212 int err;
1202 int i; 1213 int i;
1214 u32 nr_channels;
1215 dma_cap_mask_t cap_mask = {};
1216 enum atdma_devtype atdmatype;
1217
1218 dma_cap_set(DMA_MEMCPY, cap_mask);
1219
1220 /* get DMA parameters from controller type */
1221 atdmatype = platform_get_device_id(pdev)->driver_data;
1203 1222
1204 /* get DMA Controller parameters from platform */ 1223 switch (atdmatype) {
1205 pdata = pdev->dev.platform_data; 1224 case ATDMA_DEVTYPE_SAM9RL:
1206 if (!pdata || pdata->nr_channels > AT_DMA_MAX_NR_CHANNELS) 1225 nr_channels = 2;
1226 break;
1227 case ATDMA_DEVTYPE_SAM9G45:
1228 nr_channels = 8;
1229 dma_cap_set(DMA_SLAVE, cap_mask);
1230 break;
1231 default:
1207 return -EINVAL; 1232 return -EINVAL;
1233 }
1208 1234
1209 io = platform_get_resource(pdev, IORESOURCE_MEM, 0); 1235 io = platform_get_resource(pdev, IORESOURCE_MEM, 0);
1210 if (!io) 1236 if (!io)
@@ -1215,14 +1241,15 @@ static int __init at_dma_probe(struct platform_device *pdev)
1215 return irq; 1241 return irq;
1216 1242
1217 size = sizeof(struct at_dma); 1243 size = sizeof(struct at_dma);
1218 size += pdata->nr_channels * sizeof(struct at_dma_chan); 1244 size += nr_channels * sizeof(struct at_dma_chan);
1219 atdma = kzalloc(size, GFP_KERNEL); 1245 atdma = kzalloc(size, GFP_KERNEL);
1220 if (!atdma) 1246 if (!atdma)
1221 return -ENOMEM; 1247 return -ENOMEM;
1222 1248
1223 /* discover transaction capabilites from the platform data */ 1249 /* discover transaction capabilities */
1224 atdma->dma_common.cap_mask = pdata->cap_mask; 1250 atdma->dma_common.cap_mask = cap_mask;
1225 atdma->all_chan_mask = (1 << pdata->nr_channels) - 1; 1251 atdma->all_chan_mask = (1 << nr_channels) - 1;
1252 atdma->devtype = atdmatype;
1226 1253
1227 size = resource_size(io); 1254 size = resource_size(io);
1228 if (!request_mem_region(io->start, size, pdev->dev.driver->name)) { 1255 if (!request_mem_region(io->start, size, pdev->dev.driver->name)) {
@@ -1268,7 +1295,7 @@ static int __init at_dma_probe(struct platform_device *pdev)
1268 1295
1269 /* initialize channels related values */ 1296 /* initialize channels related values */
1270 INIT_LIST_HEAD(&atdma->dma_common.channels); 1297 INIT_LIST_HEAD(&atdma->dma_common.channels);
1271 for (i = 0; i < pdata->nr_channels; i++) { 1298 for (i = 0; i < nr_channels; i++) {
1272 struct at_dma_chan *atchan = &atdma->chan[i]; 1299 struct at_dma_chan *atchan = &atdma->chan[i];
1273 1300
1274 atchan->chan_common.device = &atdma->dma_common; 1301 atchan->chan_common.device = &atdma->dma_common;
@@ -1313,7 +1340,7 @@ static int __init at_dma_probe(struct platform_device *pdev)
1313 dev_info(&pdev->dev, "Atmel AHB DMA Controller ( %s%s), %d channels\n", 1340 dev_info(&pdev->dev, "Atmel AHB DMA Controller ( %s%s), %d channels\n",
1314 dma_has_cap(DMA_MEMCPY, atdma->dma_common.cap_mask) ? "cpy " : "", 1341 dma_has_cap(DMA_MEMCPY, atdma->dma_common.cap_mask) ? "cpy " : "",
1315 dma_has_cap(DMA_SLAVE, atdma->dma_common.cap_mask) ? "slave " : "", 1342 dma_has_cap(DMA_SLAVE, atdma->dma_common.cap_mask) ? "slave " : "",
1316 pdata->nr_channels); 1343 nr_channels);
1317 1344
1318 dma_async_device_register(&atdma->dma_common); 1345 dma_async_device_register(&atdma->dma_common);
1319 1346
@@ -1495,6 +1522,7 @@ static const struct dev_pm_ops at_dma_dev_pm_ops = {
1495static struct platform_driver at_dma_driver = { 1522static struct platform_driver at_dma_driver = {
1496 .remove = __exit_p(at_dma_remove), 1523 .remove = __exit_p(at_dma_remove),
1497 .shutdown = at_dma_shutdown, 1524 .shutdown = at_dma_shutdown,
1525 .id_table = atdma_devtypes,
1498 .driver = { 1526 .driver = {
1499 .name = "at_hdmac", 1527 .name = "at_hdmac",
1500 .pm = &at_dma_dev_pm_ops, 1528 .pm = &at_dma_dev_pm_ops,
diff --git a/drivers/dma/at_hdmac_regs.h b/drivers/dma/at_hdmac_regs.h
index aa4c9aebab7c..d7d67372e4ff 100644
--- a/drivers/dma/at_hdmac_regs.h
+++ b/drivers/dma/at_hdmac_regs.h
@@ -248,9 +248,16 @@ static inline struct at_dma_chan *to_at_dma_chan(struct dma_chan *dchan)
248 248
249/*-- Controller ------------------------------------------------------*/ 249/*-- Controller ------------------------------------------------------*/
250 250
251enum atdma_devtype {
252 ATDMA_DEVTYPE_UNDEFINED = 0,
253 ATDMA_DEVTYPE_SAM9RL, /* compatible with SAM9RL DMA controller */
254 ATDMA_DEVTYPE_SAM9G45, /* compatible with SAM9G45 DMA controller */
255};
256
251/** 257/**
252 * struct at_dma - internal representation of an Atmel HDMA Controller 258 * struct at_dma - internal representation of an Atmel HDMA Controller
253 * @chan_common: common dmaengine dma_device object members 259 * @chan_common: common dmaengine dma_device object members
260 * @atdma_devtype: identifier of DMA controller compatibility
254 * @ch_regs: memory mapped register base 261 * @ch_regs: memory mapped register base
255 * @clk: dma controller clock 262 * @clk: dma controller clock
256 * @save_imr: interrupt mask register that is saved on suspend/resume cycle 263 * @save_imr: interrupt mask register that is saved on suspend/resume cycle
@@ -260,6 +267,7 @@ static inline struct at_dma_chan *to_at_dma_chan(struct dma_chan *dchan)
260 */ 267 */
261struct at_dma { 268struct at_dma {
262 struct dma_device dma_common; 269 struct dma_device dma_common;
270 enum atdma_devtype devtype;
263 void __iomem *regs; 271 void __iomem *regs;
264 struct clk *clk; 272 struct clk *clk;
265 u32 save_imr; 273 u32 save_imr;