1 /* linux/drivers/dma/pl330.c
3 * Copyright (C) 2010 Samsung Electronics Co. Ltd.
4 * Jaswinder Singh <jassi.brar@samsung.com>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
13 #include <linux/init.h>
14 #include <linux/slab.h>
15 #include <linux/module.h>
16 #include <linux/dmaengine.h>
17 #include <linux/interrupt.h>
18 #include <linux/amba/bus.h>
19 #include <linux/amba/pl330.h>
20 #include <linux/pm_runtime.h>
21 #include <linux/scatterlist.h>
24 #include "dmaengine.h"
26 #define NR_DEFAULT_DESC 16
29 /* In the DMAC pool */
32 * Allocted to some channel during prep_xxx
33 * Also may be sitting on the work_list.
37 * Sitting on the work_list and already submitted
38 * to the PL330 core. Not more than two descriptors
39 * of a channel can be BUSY at any time.
43 * Sitting on the channel work_list but xfer done
49 struct dma_pl330_chan {
50 /* Schedule desc completion */
51 struct tasklet_struct task;
53 /* DMA-Engine Channel */
56 /* List of to be xfered descriptors */
57 struct list_head work_list;
59 /* Pointer to the DMAC that manages this channel,
60 * NULL if the channel is available to be acquired.
61 * As the parent, this DMAC also provides descriptors
64 struct dma_pl330_dmac *dmac;
66 /* To protect channel manipulation */
69 /* Token of a hardware channel thread of PL330 DMAC
70 * NULL if the channel is available to be acquired.
74 /* For D-to-M and M-to-D channels */
75 int burst_sz; /* the peripheral fifo width */
76 int burst_len; /* the number of burst */
79 /* for cyclic capability */
83 struct dma_pl330_dmac {
84 struct pl330_info pif;
86 /* DMA-Engine Device */
87 struct dma_device ddma;
89 /* Pool of descriptors available for the DMAC's channels */
90 struct list_head desc_pool;
91 /* To protect desc_pool manipulation */
94 /* Peripheral channels connected to this DMAC */
95 struct dma_pl330_chan *peripherals; /* keep at end */
100 struct dma_pl330_desc {
101 /* To attach to a queue as child */
102 struct list_head node;
104 /* Descriptor for the DMA Engine API */
105 struct dma_async_tx_descriptor txd;
107 /* Xfer for PL330 core */
108 struct pl330_xfer px;
110 struct pl330_reqcfg rqcfg;
111 struct pl330_req req;
113 enum desc_status status;
115 /* The channel which currently holds this desc */
116 struct dma_pl330_chan *pchan;
119 /* forward declaration */
120 static struct amba_driver pl330_driver;
122 static inline struct dma_pl330_chan *
123 to_pchan(struct dma_chan *ch)
128 return container_of(ch, struct dma_pl330_chan, chan);
131 static inline struct dma_pl330_desc *
132 to_desc(struct dma_async_tx_descriptor *tx)
134 return container_of(tx, struct dma_pl330_desc, txd);
137 static inline void free_desc_list(struct list_head *list)
139 struct dma_pl330_dmac *pdmac;
140 struct dma_pl330_desc *desc;
141 struct dma_pl330_chan *pch;
144 if (list_empty(list))
147 /* Finish off the work list */
148 list_for_each_entry(desc, list, node) {
149 dma_async_tx_callback callback;
152 /* All desc in a list belong to same channel */
154 callback = desc->txd.callback;
155 param = desc->txd.callback_param;
165 spin_lock_irqsave(&pdmac->pool_lock, flags);
166 list_splice_tail_init(list, &pdmac->desc_pool);
167 spin_unlock_irqrestore(&pdmac->pool_lock, flags);
170 static inline void handle_cyclic_desc_list(struct list_head *list)
172 struct dma_pl330_desc *desc;
173 struct dma_pl330_chan *pch;
176 if (list_empty(list))
179 list_for_each_entry(desc, list, node) {
180 dma_async_tx_callback callback;
182 /* Change status to reload it */
185 callback = desc->txd.callback;
187 callback(desc->txd.callback_param);
190 spin_lock_irqsave(&pch->lock, flags);
191 list_splice_tail_init(list, &pch->work_list);
192 spin_unlock_irqrestore(&pch->lock, flags);
195 static inline void fill_queue(struct dma_pl330_chan *pch)
197 struct dma_pl330_desc *desc;
200 list_for_each_entry(desc, &pch->work_list, node) {
202 /* If already submitted */
203 if (desc->status == BUSY)
206 ret = pl330_submit_req(pch->pl330_chid,
211 } else if (ret == -EAGAIN) {
212 /* QFull or DMAC Dying */
215 /* Unacceptable request */
217 dev_err(pch->dmac->pif.dev, "%s:%d Bad Desc(%d)\n",
218 __func__, __LINE__, desc->txd.cookie);
219 tasklet_schedule(&pch->task);
224 static void pl330_tasklet(unsigned long data)
226 struct dma_pl330_chan *pch = (struct dma_pl330_chan *)data;
227 struct dma_pl330_desc *desc, *_dt;
231 spin_lock_irqsave(&pch->lock, flags);
233 /* Pick up ripe tomatoes */
234 list_for_each_entry_safe(desc, _dt, &pch->work_list, node)
235 if (desc->status == DONE) {
236 pch->chan.completed_cookie = desc->txd.cookie;
237 list_move_tail(&desc->node, &list);
240 /* Try to submit a req imm. next to the last completed cookie */
243 /* Make sure the PL330 Channel thread is active */
244 pl330_chan_ctrl(pch->pl330_chid, PL330_OP_START);
246 spin_unlock_irqrestore(&pch->lock, flags);
249 handle_cyclic_desc_list(&list);
251 free_desc_list(&list);
254 static void dma_pl330_rqcb(void *token, enum pl330_op_err err)
256 struct dma_pl330_desc *desc = token;
257 struct dma_pl330_chan *pch = desc->pchan;
260 /* If desc aborted */
264 spin_lock_irqsave(&pch->lock, flags);
268 spin_unlock_irqrestore(&pch->lock, flags);
270 tasklet_schedule(&pch->task);
273 bool pl330_filter(struct dma_chan *chan, void *param)
277 if (chan->device->dev->driver != &pl330_driver.drv)
281 if (chan->device->dev->of_node) {
282 const __be32 *prop_value;
284 struct device_node *node;
286 prop_value = ((struct property *)param)->value;
287 phandle = be32_to_cpup(prop_value++);
288 node = of_find_node_by_phandle(phandle);
289 return ((chan->private == node) &&
290 (chan->chan_id == be32_to_cpup(prop_value)));
294 peri_id = chan->private;
295 return *peri_id == (unsigned)param;
297 EXPORT_SYMBOL(pl330_filter);
299 static int pl330_alloc_chan_resources(struct dma_chan *chan)
301 struct dma_pl330_chan *pch = to_pchan(chan);
302 struct dma_pl330_dmac *pdmac = pch->dmac;
305 spin_lock_irqsave(&pch->lock, flags);
307 chan->completed_cookie = chan->cookie = 1;
310 pch->pl330_chid = pl330_request_channel(&pdmac->pif);
311 if (!pch->pl330_chid) {
312 spin_unlock_irqrestore(&pch->lock, flags);
316 tasklet_init(&pch->task, pl330_tasklet, (unsigned long) pch);
318 spin_unlock_irqrestore(&pch->lock, flags);
323 static int pl330_control(struct dma_chan *chan, enum dma_ctrl_cmd cmd, unsigned long arg)
325 struct dma_pl330_chan *pch = to_pchan(chan);
326 struct dma_pl330_desc *desc, *_dt;
328 struct dma_pl330_dmac *pdmac = pch->dmac;
329 struct dma_slave_config *slave_config;
333 case DMA_TERMINATE_ALL:
334 spin_lock_irqsave(&pch->lock, flags);
336 /* FLUSH the PL330 Channel thread */
337 pl330_chan_ctrl(pch->pl330_chid, PL330_OP_FLUSH);
339 /* Mark all desc done */
340 list_for_each_entry_safe(desc, _dt, &pch->work_list , node) {
342 pch->completed = desc->txd.cookie;
343 list_move_tail(&desc->node, &list);
346 list_splice_tail_init(&list, &pdmac->desc_pool);
347 spin_unlock_irqrestore(&pch->lock, flags);
349 case DMA_SLAVE_CONFIG:
350 slave_config = (struct dma_slave_config *)arg;
352 if (slave_config->direction == DMA_MEM_TO_DEV) {
353 if (slave_config->dst_addr)
354 pch->fifo_addr = slave_config->dst_addr;
355 if (slave_config->dst_addr_width)
356 pch->burst_sz = __ffs(slave_config->dst_addr_width);
357 if (slave_config->dst_maxburst)
358 pch->burst_len = slave_config->dst_maxburst;
359 } else if (slave_config->direction == DMA_DEV_TO_MEM) {
360 if (slave_config->src_addr)
361 pch->fifo_addr = slave_config->src_addr;
362 if (slave_config->src_addr_width)
363 pch->burst_sz = __ffs(slave_config->src_addr_width);
364 if (slave_config->src_maxburst)
365 pch->burst_len = slave_config->src_maxburst;
369 dev_err(pch->dmac->pif.dev, "Not supported command.\n");
376 static void pl330_free_chan_resources(struct dma_chan *chan)
378 struct dma_pl330_chan *pch = to_pchan(chan);
381 spin_lock_irqsave(&pch->lock, flags);
383 tasklet_kill(&pch->task);
385 pl330_release_channel(pch->pl330_chid);
386 pch->pl330_chid = NULL;
389 list_splice_tail_init(&pch->work_list, &pch->dmac->desc_pool);
391 spin_unlock_irqrestore(&pch->lock, flags);
394 static enum dma_status
395 pl330_tx_status(struct dma_chan *chan, dma_cookie_t cookie,
396 struct dma_tx_state *txstate)
398 struct dma_pl330_chan *pch = to_pchan(chan);
399 dma_cookie_t last_done, last_used;
402 last_done = chan->completed_cookie;
403 last_used = chan->cookie;
405 ret = dma_async_is_complete(cookie, last_done, last_used);
407 dma_set_tx_state(txstate, last_done, last_used, 0);
412 static void pl330_issue_pending(struct dma_chan *chan)
414 pl330_tasklet((unsigned long) to_pchan(chan));
418 * We returned the last one of the circular list of descriptor(s)
419 * from prep_xxx, so the argument to submit corresponds to the last
420 * descriptor of the list.
422 static dma_cookie_t pl330_tx_submit(struct dma_async_tx_descriptor *tx)
424 struct dma_pl330_desc *desc, *last = to_desc(tx);
425 struct dma_pl330_chan *pch = to_pchan(tx->chan);
429 spin_lock_irqsave(&pch->lock, flags);
431 /* Assign cookies to all nodes */
432 cookie = tx->chan->cookie;
434 while (!list_empty(&last->node)) {
435 desc = list_entry(last->node.next, struct dma_pl330_desc, node);
439 desc->txd.cookie = cookie;
441 list_move_tail(&desc->node, &pch->work_list);
446 last->txd.cookie = cookie;
448 list_add_tail(&last->node, &pch->work_list);
450 tx->chan->cookie = cookie;
452 spin_unlock_irqrestore(&pch->lock, flags);
457 static inline void _init_desc(struct dma_pl330_desc *desc)
460 desc->req.x = &desc->px;
461 desc->req.token = desc;
462 desc->rqcfg.swap = SWAP_NO;
463 desc->rqcfg.privileged = 0;
464 desc->rqcfg.insnaccess = 0;
465 desc->rqcfg.scctl = SCCTRL0;
466 desc->rqcfg.dcctl = DCCTRL0;
467 desc->req.cfg = &desc->rqcfg;
468 desc->req.xfer_cb = dma_pl330_rqcb;
469 desc->txd.tx_submit = pl330_tx_submit;
471 INIT_LIST_HEAD(&desc->node);
474 /* Returns the number of descriptors added to the DMAC pool */
475 int add_desc(struct dma_pl330_dmac *pdmac, gfp_t flg, int count)
477 struct dma_pl330_desc *desc;
484 desc = kmalloc(count * sizeof(*desc), flg);
488 spin_lock_irqsave(&pdmac->pool_lock, flags);
490 for (i = 0; i < count; i++) {
491 _init_desc(&desc[i]);
492 list_add_tail(&desc[i].node, &pdmac->desc_pool);
495 spin_unlock_irqrestore(&pdmac->pool_lock, flags);
500 static struct dma_pl330_desc *
501 pluck_desc(struct dma_pl330_dmac *pdmac)
503 struct dma_pl330_desc *desc = NULL;
509 spin_lock_irqsave(&pdmac->pool_lock, flags);
511 if (!list_empty(&pdmac->desc_pool)) {
512 desc = list_entry(pdmac->desc_pool.next,
513 struct dma_pl330_desc, node);
515 list_del_init(&desc->node);
518 desc->txd.callback = NULL;
521 spin_unlock_irqrestore(&pdmac->pool_lock, flags);
526 static struct dma_pl330_desc *pl330_get_desc(struct dma_pl330_chan *pch)
528 struct dma_pl330_dmac *pdmac = pch->dmac;
529 u8 *peri_id = pch->chan.private;
530 struct dma_pl330_desc *desc;
532 /* Pluck one desc from the pool of DMAC */
533 desc = pluck_desc(pdmac);
535 /* If the DMAC pool is empty, alloc new */
537 if (!add_desc(pdmac, GFP_ATOMIC, 1))
541 desc = pluck_desc(pdmac);
543 dev_err(pch->dmac->pif.dev,
544 "%s:%d ALERT!\n", __func__, __LINE__);
549 /* Initialize the descriptor */
551 desc->txd.cookie = 0;
552 async_tx_ack(&desc->txd);
554 desc->req.peri = peri_id ? pch->chan.chan_id : 0;
556 dma_async_tx_descriptor_init(&desc->txd, &pch->chan);
561 static inline void fill_px(struct pl330_xfer *px,
562 dma_addr_t dst, dma_addr_t src, size_t len)
570 static struct dma_pl330_desc *
571 __pl330_prep_dma_memcpy(struct dma_pl330_chan *pch, dma_addr_t dst,
572 dma_addr_t src, size_t len)
574 struct dma_pl330_desc *desc = pl330_get_desc(pch);
577 dev_err(pch->dmac->pif.dev, "%s:%d Unable to fetch desc\n",
583 * Ideally we should lookout for reqs bigger than
584 * those that can be programmed with 256 bytes of
585 * MC buffer, but considering a req size is seldom
586 * going to be word-unaligned and more than 200MB,
588 * Also, should the limit is reached we'd rather
589 * have the platform increase MC buffer size than
590 * complicating this API driver.
592 fill_px(&desc->px, dst, src, len);
597 /* Call after fixing burst size */
598 static inline int get_burst_len(struct dma_pl330_desc *desc, size_t len)
600 struct dma_pl330_chan *pch = desc->pchan;
601 struct pl330_info *pi = &pch->dmac->pif;
604 burst_len = pi->pcfg.data_bus_width / 8;
605 burst_len *= pi->pcfg.data_buf_dep;
606 burst_len >>= desc->rqcfg.brst_size;
608 /* src/dst_burst_len can't be more than 16 */
612 while (burst_len > 1) {
613 if (!(len % (burst_len << desc->rqcfg.brst_size)))
621 static struct dma_async_tx_descriptor *pl330_prep_dma_cyclic(
622 struct dma_chan *chan, dma_addr_t dma_addr, size_t len,
623 size_t period_len, enum dma_transfer_direction direction)
625 struct dma_pl330_desc *desc;
626 struct dma_pl330_chan *pch = to_pchan(chan);
630 desc = pl330_get_desc(pch);
632 dev_err(pch->dmac->pif.dev, "%s:%d Unable to fetch desc\n",
639 desc->rqcfg.src_inc = 1;
640 desc->rqcfg.dst_inc = 0;
641 desc->req.rqtype = MEMTODEV;
643 dst = pch->fifo_addr;
646 desc->rqcfg.src_inc = 0;
647 desc->rqcfg.dst_inc = 1;
648 desc->req.rqtype = DEVTOMEM;
649 src = pch->fifo_addr;
653 dev_err(pch->dmac->pif.dev, "%s:%d Invalid dma direction\n",
658 desc->rqcfg.brst_size = pch->burst_sz;
659 desc->rqcfg.brst_len = 1;
663 fill_px(&desc->px, dst, src, period_len);
668 static struct dma_async_tx_descriptor *
669 pl330_prep_dma_memcpy(struct dma_chan *chan, dma_addr_t dst,
670 dma_addr_t src, size_t len, unsigned long flags)
672 struct dma_pl330_desc *desc;
673 struct dma_pl330_chan *pch = to_pchan(chan);
674 struct pl330_info *pi;
677 if (unlikely(!pch || !len))
680 pi = &pch->dmac->pif;
682 desc = __pl330_prep_dma_memcpy(pch, dst, src, len);
686 desc->rqcfg.src_inc = 1;
687 desc->rqcfg.dst_inc = 1;
688 desc->req.rqtype = MEMTOMEM;
690 /* Select max possible burst size */
691 burst = pi->pcfg.data_bus_width / 8;
699 desc->rqcfg.brst_size = 0;
700 while (burst != (1 << desc->rqcfg.brst_size))
701 desc->rqcfg.brst_size++;
703 desc->rqcfg.brst_len = get_burst_len(desc, len);
705 desc->txd.flags = flags;
710 static struct dma_async_tx_descriptor *
711 pl330_prep_slave_sg(struct dma_chan *chan, struct scatterlist *sgl,
712 unsigned int sg_len, enum dma_transfer_direction direction,
715 struct dma_pl330_desc *first, *desc = NULL;
716 struct dma_pl330_chan *pch = to_pchan(chan);
717 struct scatterlist *sg;
722 if (unlikely(!pch || !sgl || !sg_len))
725 addr = pch->fifo_addr;
729 for_each_sg(sgl, sg, sg_len, i) {
731 desc = pl330_get_desc(pch);
733 struct dma_pl330_dmac *pdmac = pch->dmac;
735 dev_err(pch->dmac->pif.dev,
736 "%s:%d Unable to fetch desc\n",
741 spin_lock_irqsave(&pdmac->pool_lock, flags);
743 while (!list_empty(&first->node)) {
744 desc = list_entry(first->node.next,
745 struct dma_pl330_desc, node);
746 list_move_tail(&desc->node, &pdmac->desc_pool);
749 list_move_tail(&first->node, &pdmac->desc_pool);
751 spin_unlock_irqrestore(&pdmac->pool_lock, flags);
759 list_add_tail(&desc->node, &first->node);
761 if (direction == DMA_MEM_TO_DEV) {
762 desc->rqcfg.src_inc = 1;
763 desc->rqcfg.dst_inc = 0;
764 desc->req.rqtype = MEMTODEV;
766 addr, sg_dma_address(sg), sg_dma_len(sg));
768 desc->rqcfg.src_inc = 0;
769 desc->rqcfg.dst_inc = 1;
770 desc->req.rqtype = DEVTOMEM;
772 sg_dma_address(sg), addr, sg_dma_len(sg));
775 desc->rqcfg.brst_size = pch->burst_sz;
776 desc->rqcfg.brst_len = 1;
779 /* Return the last desc in the chain */
780 desc->txd.flags = flg;
784 static irqreturn_t pl330_irq_handler(int irq, void *data)
786 if (pl330_update(data))
793 pl330_probe(struct amba_device *adev, const struct amba_id *id)
795 struct dma_pl330_platdata *pdat;
796 struct dma_pl330_dmac *pdmac;
797 struct dma_pl330_chan *pch;
798 struct pl330_info *pi;
799 struct dma_device *pd;
800 struct resource *res;
804 pdat = adev->dev.platform_data;
806 /* Allocate a new DMAC and its Channels */
807 pdmac = kzalloc(sizeof(*pdmac), GFP_KERNEL);
809 dev_err(&adev->dev, "unable to allocate mem\n");
814 pi->dev = &adev->dev;
815 pi->pl330_data = NULL;
816 pi->mcbufsz = pdat ? pdat->mcbuf_sz : 0;
819 request_mem_region(res->start, resource_size(res), "dma-pl330");
821 pi->base = ioremap(res->start, resource_size(res));
827 pdmac->clk = clk_get(&adev->dev, "dma");
828 if (IS_ERR(pdmac->clk)) {
829 dev_err(&adev->dev, "Cannot get operation clock.\n");
834 amba_set_drvdata(adev, pdmac);
836 #ifndef CONFIG_PM_RUNTIME
838 clk_enable(pdmac->clk);
842 ret = request_irq(irq, pl330_irq_handler, 0,
843 dev_name(&adev->dev), pi);
851 INIT_LIST_HEAD(&pdmac->desc_pool);
852 spin_lock_init(&pdmac->pool_lock);
854 /* Create a descriptor pool of default size */
855 if (!add_desc(pdmac, GFP_KERNEL, NR_DEFAULT_DESC))
856 dev_warn(&adev->dev, "unable to allocate desc\n");
859 INIT_LIST_HEAD(&pd->channels);
861 /* Initialize channel parameters */
862 num_chan = max(pdat ? pdat->nr_valid_peri : (u8)pi->pcfg.num_peri,
863 (u8)pi->pcfg.num_chan);
864 pdmac->peripherals = kzalloc(num_chan * sizeof(*pch), GFP_KERNEL);
866 for (i = 0; i < num_chan; i++) {
867 pch = &pdmac->peripherals[i];
868 if (!adev->dev.of_node)
869 pch->chan.private = pdat ? &pdat->peri_id[i] : NULL;
871 pch->chan.private = adev->dev.of_node;
873 INIT_LIST_HEAD(&pch->work_list);
874 spin_lock_init(&pch->lock);
875 pch->pl330_chid = NULL;
876 pch->chan.device = pd;
879 /* Add the channel to the DMAC list */
880 list_add_tail(&pch->chan.device_node, &pd->channels);
883 pd->dev = &adev->dev;
885 pd->cap_mask = pdat->cap_mask;
887 dma_cap_set(DMA_MEMCPY, pd->cap_mask);
888 if (pi->pcfg.num_peri) {
889 dma_cap_set(DMA_SLAVE, pd->cap_mask);
890 dma_cap_set(DMA_CYCLIC, pd->cap_mask);
894 pd->device_alloc_chan_resources = pl330_alloc_chan_resources;
895 pd->device_free_chan_resources = pl330_free_chan_resources;
896 pd->device_prep_dma_memcpy = pl330_prep_dma_memcpy;
897 pd->device_prep_dma_cyclic = pl330_prep_dma_cyclic;
898 pd->device_tx_status = pl330_tx_status;
899 pd->device_prep_slave_sg = pl330_prep_slave_sg;
900 pd->device_control = pl330_control;
901 pd->device_issue_pending = pl330_issue_pending;
903 ret = dma_async_device_register(pd);
905 dev_err(&adev->dev, "unable to register DMAC\n");
910 "Loaded driver for PL330 DMAC-%d\n", adev->periphid);
912 "\tDBUFF-%ux%ubytes Num_Chans-%u Num_Peri-%u Num_Events-%u\n",
913 pi->pcfg.data_buf_dep,
914 pi->pcfg.data_bus_width / 8, pi->pcfg.num_chan,
915 pi->pcfg.num_peri, pi->pcfg.num_events);
924 #ifndef CONFIG_PM_RUNTIME
925 clk_disable(pdmac->clk);
931 release_mem_region(res->start, resource_size(res));
937 static int __devexit pl330_remove(struct amba_device *adev)
939 struct dma_pl330_dmac *pdmac = amba_get_drvdata(adev);
940 struct dma_pl330_chan *pch, *_p;
941 struct pl330_info *pi;
942 struct resource *res;
948 amba_set_drvdata(adev, NULL);
951 list_for_each_entry_safe(pch, _p, &pdmac->ddma.channels,
954 /* Remove the channel */
955 list_del(&pch->chan.device_node);
957 /* Flush the channel */
958 pl330_control(&pch->chan, DMA_TERMINATE_ALL, 0);
959 pl330_free_chan_resources(&pch->chan);
972 release_mem_region(res->start, resource_size(res));
974 #ifndef CONFIG_PM_RUNTIME
975 clk_disable(pdmac->clk);
983 static struct amba_id pl330_ids[] = {
991 MODULE_DEVICE_TABLE(amba, pl330_ids);
993 #ifdef CONFIG_PM_RUNTIME
994 static int pl330_runtime_suspend(struct device *dev)
996 struct dma_pl330_dmac *pdmac = dev_get_drvdata(dev);
999 dev_err(dev, "failed to get dmac\n");
1003 clk_disable(pdmac->clk);
1008 static int pl330_runtime_resume(struct device *dev)
1010 struct dma_pl330_dmac *pdmac = dev_get_drvdata(dev);
1013 dev_err(dev, "failed to get dmac\n");
1017 clk_enable(pdmac->clk);
1022 #define pl330_runtime_suspend NULL
1023 #define pl330_runtime_resume NULL
1024 #endif /* CONFIG_PM_RUNTIME */
1026 static const struct dev_pm_ops pl330_pm_ops = {
1027 .runtime_suspend = pl330_runtime_suspend,
1028 .runtime_resume = pl330_runtime_resume,
1031 static struct amba_driver pl330_driver = {
1033 .owner = THIS_MODULE,
1034 .name = "dma-pl330",
1035 .pm = &pl330_pm_ops,
1037 .id_table = pl330_ids,
1038 .probe = pl330_probe,
1039 .remove = pl330_remove,
1042 static int __init pl330_init(void)
1044 return amba_driver_register(&pl330_driver);
1046 module_init(pl330_init);
1048 static void __exit pl330_exit(void)
1050 amba_driver_unregister(&pl330_driver);
1053 module_exit(pl330_exit);
1055 MODULE_AUTHOR("Jaswinder Singh <jassi.brar@samsung.com>");
1056 MODULE_DESCRIPTION("API Driver for PL330 DMAC");
1057 MODULE_LICENSE("GPL");