Loading...
1/* SPDX-License-Identifier: GPL-2.0 */
2/*
3 * Driver for the Synopsys DesignWare DMA Controller
4 *
5 * Copyright (C) 2013 Intel Corporation
6 */
7
8#ifndef _DMA_DW_INTERNAL_H
9#define _DMA_DW_INTERNAL_H
10
11#include <linux/dma/dw.h>
12
13#include "regs.h"
14
15int do_dma_probe(struct dw_dma_chip *chip);
16int do_dma_remove(struct dw_dma_chip *chip);
17
18void do_dw_dma_on(struct dw_dma *dw);
19void do_dw_dma_off(struct dw_dma *dw);
20
21int do_dw_dma_disable(struct dw_dma_chip *chip);
22int do_dw_dma_enable(struct dw_dma_chip *chip);
23
24extern bool dw_dma_filter(struct dma_chan *chan, void *param);
25
26#ifdef CONFIG_ACPI
27void dw_dma_acpi_controller_register(struct dw_dma *dw);
28void dw_dma_acpi_controller_free(struct dw_dma *dw);
29#else /* !CONFIG_ACPI */
30static inline void dw_dma_acpi_controller_register(struct dw_dma *dw) {}
31static inline void dw_dma_acpi_controller_free(struct dw_dma *dw) {}
32#endif /* !CONFIG_ACPI */
33
34struct platform_device;
35
36#ifdef CONFIG_OF
37struct dw_dma_platform_data *dw_dma_parse_dt(struct platform_device *pdev);
38void dw_dma_of_controller_register(struct dw_dma *dw);
39void dw_dma_of_controller_free(struct dw_dma *dw);
40#else
41static inline struct dw_dma_platform_data *dw_dma_parse_dt(struct platform_device *pdev)
42{
43 return NULL;
44}
45static inline void dw_dma_of_controller_register(struct dw_dma *dw) {}
46static inline void dw_dma_of_controller_free(struct dw_dma *dw) {}
47#endif
48
49struct dw_dma_chip_pdata {
50 const struct dw_dma_platform_data *pdata;
51 int (*probe)(struct dw_dma_chip *chip);
52 int (*remove)(struct dw_dma_chip *chip);
53 struct dw_dma_chip *chip;
54};
55
56static __maybe_unused const struct dw_dma_chip_pdata dw_dma_chip_pdata = {
57 .probe = dw_dma_probe,
58 .remove = dw_dma_remove,
59};
60
61static const struct dw_dma_platform_data idma32_pdata = {
62 .nr_channels = 8,
63 .chan_allocation_order = CHAN_ALLOCATION_ASCENDING,
64 .chan_priority = CHAN_PRIORITY_ASCENDING,
65 .block_size = 131071,
66 .nr_masters = 1,
67 .data_width = {4},
68 .multi_block = {1, 1, 1, 1, 1, 1, 1, 1},
69};
70
71static __maybe_unused const struct dw_dma_chip_pdata idma32_chip_pdata = {
72 .pdata = &idma32_pdata,
73 .probe = idma32_dma_probe,
74 .remove = idma32_dma_remove,
75};
76
77#endif /* _DMA_DW_INTERNAL_H */
1/*
2 * Driver for the Synopsys DesignWare DMA Controller
3 *
4 * Copyright (C) 2013 Intel Corporation
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 */
10
11#ifndef _DW_DMAC_INTERNAL_H
12#define _DW_DMAC_INTERNAL_H
13
14#include <linux/device.h>
15#include <linux/dw_dmac.h>
16
17#include "regs.h"
18
19/**
20 * struct dw_dma_chip - representation of DesignWare DMA controller hardware
21 * @dev: struct device of the DMA controller
22 * @irq: irq line
23 * @regs: memory mapped I/O space
24 * @dw: struct dw_dma that is filed by dw_dma_probe()
25 */
26struct dw_dma_chip {
27 struct device *dev;
28 int irq;
29 void __iomem *regs;
30 struct dw_dma *dw;
31};
32
33/* Export to the platform drivers */
34int dw_dma_probe(struct dw_dma_chip *chip, struct dw_dma_platform_data *pdata);
35int dw_dma_remove(struct dw_dma_chip *chip);
36
37void dw_dma_shutdown(struct dw_dma_chip *chip);
38
39#ifdef CONFIG_PM_SLEEP
40
41int dw_dma_suspend(struct dw_dma_chip *chip);
42int dw_dma_resume(struct dw_dma_chip *chip);
43
44#endif /* CONFIG_PM_SLEEP */
45
46/**
47 * dwc_get_dms - get destination master
48 * @slave: pointer to the custom slave configuration
49 *
50 * Returns destination master in the custom slave configuration if defined, or
51 * default value otherwise.
52 */
53static inline unsigned int dwc_get_dms(struct dw_dma_slave *slave)
54{
55 return slave ? slave->dst_master : 0;
56}
57
58/**
59 * dwc_get_sms - get source master
60 * @slave: pointer to the custom slave configuration
61 *
62 * Returns source master in the custom slave configuration if defined, or
63 * default value otherwise.
64 */
65static inline unsigned int dwc_get_sms(struct dw_dma_slave *slave)
66{
67 return slave ? slave->src_master : 1;
68}
69
70#endif /* _DW_DMAC_INTERNAL_H */