xref: /openbmc/qemu/include/hw/dma/sifive_pdma.h (revision d6271b657286de80260413684a1f2a63f44ea17b)
197ba4223SBin Meng /*
297ba4223SBin Meng  * SiFive Platform DMA emulation
397ba4223SBin Meng  *
497ba4223SBin Meng  * Copyright (c) 2020 Wind River Systems, Inc.
597ba4223SBin Meng  *
697ba4223SBin Meng  * Author:
797ba4223SBin Meng  *   Bin Meng <bin.meng@windriver.com>
897ba4223SBin Meng  *
997ba4223SBin Meng  * This program is free software; you can redistribute it and/or
1097ba4223SBin Meng  * modify it under the terms of the GNU General Public License as
1197ba4223SBin Meng  * published by the Free Software Foundation; either version 2 or
1297ba4223SBin Meng  * (at your option) version 3 of the License.
1397ba4223SBin Meng  *
1497ba4223SBin Meng  * This program is distributed in the hope that it will be useful,
1597ba4223SBin Meng  * but WITHOUT ANY WARRANTY; without even the implied warranty of
1697ba4223SBin Meng  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1797ba4223SBin Meng  * GNU General Public License for more details.
1897ba4223SBin Meng  *
1997ba4223SBin Meng  * You should have received a copy of the GNU General Public License along
2097ba4223SBin Meng  * with this program; if not, see <http://www.gnu.org/licenses/>.
2197ba4223SBin Meng  */
2297ba4223SBin Meng 
2397ba4223SBin Meng #ifndef SIFIVE_PDMA_H
2497ba4223SBin Meng #define SIFIVE_PDMA_H
2597ba4223SBin Meng 
26*7a5951f6SMarkus Armbruster #include "hw/sysbus.h"
27*7a5951f6SMarkus Armbruster 
2897ba4223SBin Meng struct sifive_pdma_chan {
2997ba4223SBin Meng     uint32_t control;
3097ba4223SBin Meng     uint32_t next_config;
3197ba4223SBin Meng     uint64_t next_bytes;
3297ba4223SBin Meng     uint64_t next_dst;
3397ba4223SBin Meng     uint64_t next_src;
3497ba4223SBin Meng     uint32_t exec_config;
3597ba4223SBin Meng     uint64_t exec_bytes;
3697ba4223SBin Meng     uint64_t exec_dst;
3797ba4223SBin Meng     uint64_t exec_src;
3897ba4223SBin Meng     int state;
3997ba4223SBin Meng };
4097ba4223SBin Meng 
4197ba4223SBin Meng #define SIFIVE_PDMA_CHANS           4
4297ba4223SBin Meng #define SIFIVE_PDMA_IRQS            (SIFIVE_PDMA_CHANS * 2)
4397ba4223SBin Meng #define SIFIVE_PDMA_REG_SIZE        0x100000
4497ba4223SBin Meng #define SIFIVE_PDMA_CHAN_NO(reg)    ((reg & (SIFIVE_PDMA_REG_SIZE - 1)) >> 12)
4597ba4223SBin Meng 
4697ba4223SBin Meng typedef struct SiFivePDMAState {
4797ba4223SBin Meng     SysBusDevice parent;
4897ba4223SBin Meng     MemoryRegion iomem;
4997ba4223SBin Meng     qemu_irq irq[SIFIVE_PDMA_IRQS];
5097ba4223SBin Meng 
5197ba4223SBin Meng     struct sifive_pdma_chan chan[SIFIVE_PDMA_CHANS];
5297ba4223SBin Meng } SiFivePDMAState;
5397ba4223SBin Meng 
5497ba4223SBin Meng #define TYPE_SIFIVE_PDMA    "sifive.pdma"
5597ba4223SBin Meng 
5697ba4223SBin Meng #define SIFIVE_PDMA(obj)    \
5797ba4223SBin Meng     OBJECT_CHECK(SiFivePDMAState, (obj), TYPE_SIFIVE_PDMA)
5897ba4223SBin Meng 
5997ba4223SBin Meng #endif /* SIFIVE_PDMA_H */
60