xref: /openbmc/qemu/include/hw/dma/sifive_pdma.h (revision e4418354)
1 /*
2  * SiFive Platform DMA emulation
3  *
4  * Copyright (c) 2020 Wind River Systems, Inc.
5  *
6  * Author:
7  *   Bin Meng <bin.meng@windriver.com>
8  *
9  * This program is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU General Public License as
11  * published by the Free Software Foundation; either version 2 or
12  * (at your option) version 3 of the License.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License along
20  * with this program; if not, see <http://www.gnu.org/licenses/>.
21  */
22 
23 #ifndef SIFIVE_PDMA_H
24 #define SIFIVE_PDMA_H
25 
26 #include "hw/sysbus.h"
27 
28 struct sifive_pdma_chan {
29     uint32_t control;
30     uint32_t next_config;
31     uint64_t next_bytes;
32     uint64_t next_dst;
33     uint64_t next_src;
34     uint32_t exec_config;
35     uint64_t exec_bytes;
36     uint64_t exec_dst;
37     uint64_t exec_src;
38     int state;
39 };
40 
41 #define SIFIVE_PDMA_CHANS           4
42 #define SIFIVE_PDMA_IRQS            (SIFIVE_PDMA_CHANS * 2)
43 #define SIFIVE_PDMA_REG_SIZE        0x100000
44 #define SIFIVE_PDMA_CHAN_NO(reg)    ((reg & (SIFIVE_PDMA_REG_SIZE - 1)) >> 12)
45 
46 typedef struct SiFivePDMAState {
47     SysBusDevice parent;
48     MemoryRegion iomem;
49     qemu_irq irq[SIFIVE_PDMA_IRQS];
50 
51     struct sifive_pdma_chan chan[SIFIVE_PDMA_CHANS];
52 } SiFivePDMAState;
53 
54 #define TYPE_SIFIVE_PDMA    "sifive.pdma"
55 
56 #define SIFIVE_PDMA(obj)    \
57     OBJECT_CHECK(SiFivePDMAState, (obj), TYPE_SIFIVE_PDMA)
58 
59 #endif /* SIFIVE_PDMA_H */
60