blob: ccfd0c3777df20d2bd9c6cd1518673643369c1ad [file] [log] [blame]
Andy Shevchenko3d588f82014-09-23 17:18:11 +03001/*
2 * Driver for the Synopsys DesignWare DMA Controller
3 *
4 * Copyright (C) 2007 Atmel Corporation
5 * Copyright (C) 2010-2011 ST Microelectronics
Andy Shevchenko2a52f6e2014-09-23 17:18:15 +03006 * Copyright (C) 2014 Intel Corporation
Andy Shevchenko3d588f82014-09-23 17:18:11 +03007 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
11 */
12#ifndef _DMA_DW_H
13#define _DMA_DW_H
14
Andy Shevchenko2a52f6e2014-09-23 17:18:15 +030015#include <linux/clk.h>
16#include <linux/device.h>
Andy Shevchenko3d588f82014-09-23 17:18:11 +030017#include <linux/dmaengine.h>
18
Andy Shevchenko2a52f6e2014-09-23 17:18:15 +030019#include <linux/platform_data/dma-dw.h>
20
21struct dw_dma;
22
23/**
24 * struct dw_dma_chip - representation of DesignWare DMA controller hardware
25 * @dev: struct device of the DMA controller
26 * @irq: irq line
27 * @regs: memory mapped I/O space
28 * @clk: hclk clock
29 * @dw: struct dw_dma that is filed by dw_dma_probe()
Andy Shevchenko3a14c662016-04-27 14:15:40 +030030 * @pdata: pointer to platform data
Andy Shevchenko2a52f6e2014-09-23 17:18:15 +030031 */
32struct dw_dma_chip {
33 struct device *dev;
34 int irq;
35 void __iomem *regs;
36 struct clk *clk;
37 struct dw_dma *dw;
Andy Shevchenko3a14c662016-04-27 14:15:40 +030038
39 const struct dw_dma_platform_data *pdata;
Andy Shevchenko2a52f6e2014-09-23 17:18:15 +030040};
41
42/* Export to the platform drivers */
Andy Shevchenko19d82912016-08-17 19:20:23 +030043#if IS_ENABLED(CONFIG_DW_DMAC_CORE)
Andy Shevchenko3a14c662016-04-27 14:15:40 +030044int dw_dma_probe(struct dw_dma_chip *chip);
Andy Shevchenko2a52f6e2014-09-23 17:18:15 +030045int dw_dma_remove(struct dw_dma_chip *chip);
Andy Shevchenko19d82912016-08-17 19:20:23 +030046#else
47static inline int dw_dma_probe(struct dw_dma_chip *chip) { return -ENODEV; }
48static inline int dw_dma_remove(struct dw_dma_chip *chip) { return 0; }
49#endif /* CONFIG_DW_DMAC_CORE */
Andy Shevchenko2a52f6e2014-09-23 17:18:15 +030050
Andy Shevchenko3d588f82014-09-23 17:18:11 +030051/* DMA API extensions */
52struct dw_desc;
53
54struct dw_cyclic_desc {
55 struct dw_desc **desc;
56 unsigned long periods;
57 void (*period_callback)(void *param);
58 void *period_callback_param;
59};
60
61struct dw_cyclic_desc *dw_dma_cyclic_prep(struct dma_chan *chan,
62 dma_addr_t buf_addr, size_t buf_len, size_t period_len,
63 enum dma_transfer_direction direction);
64void dw_dma_cyclic_free(struct dma_chan *chan);
65int dw_dma_cyclic_start(struct dma_chan *chan);
66void dw_dma_cyclic_stop(struct dma_chan *chan);
67
68dma_addr_t dw_dma_get_src_addr(struct dma_chan *chan);
69
70dma_addr_t dw_dma_get_dst_addr(struct dma_chan *chan);
71
72#endif /* _DMA_DW_H */