Merge tag 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost
[cris-mirror.git] / include / linux / dma / qcom_bam_dma.h
blob077d43a358e5e14d92062d6c0d112b10e7999396
1 /*
2 * Copyright (c) 2016-2017, The Linux Foundation. All rights reserved.
4 * This software is licensed under the terms of the GNU General Public
5 * License version 2, as published by the Free Software Foundation, and
6 * may be copied, distributed, and modified under those terms.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
14 #ifndef _QCOM_BAM_DMA_H
15 #define _QCOM_BAM_DMA_H
17 #include <asm/byteorder.h>
20 * This data type corresponds to the native Command Element
21 * supported by BAM DMA Engine.
23 * @cmd_and_addr - upper 8 bits command and lower 24 bits register address.
24 * @data - for write command: content to be written into peripheral register.
25 * for read command: dest addr to write peripheral register value.
26 * @mask - register mask.
27 * @reserved - for future usage.
30 struct bam_cmd_element {
31 __le32 cmd_and_addr;
32 __le32 data;
33 __le32 mask;
34 __le32 reserved;
38 * This enum indicates the command type in a command element
40 enum bam_command_type {
41 BAM_WRITE_COMMAND = 0,
42 BAM_READ_COMMAND,
46 * prep_bam_ce_le32 - Wrapper function to prepare a single BAM command
47 * element with the data already in le32 format.
49 * @bam_ce: bam command element
50 * @addr: target address
51 * @cmd: BAM command
52 * @data: actual data for write and dest addr for read in le32
54 static inline void
55 bam_prep_ce_le32(struct bam_cmd_element *bam_ce, u32 addr,
56 enum bam_command_type cmd, __le32 data)
58 bam_ce->cmd_and_addr =
59 cpu_to_le32((addr & 0xffffff) | ((cmd & 0xff) << 24));
60 bam_ce->data = data;
61 bam_ce->mask = cpu_to_le32(0xffffffff);
65 * bam_prep_ce - Wrapper function to prepare a single BAM command element
66 * with the data.
68 * @bam_ce: BAM command element
69 * @addr: target address
70 * @cmd: BAM command
71 * @data: actual data for write and dest addr for read
73 static inline void
74 bam_prep_ce(struct bam_cmd_element *bam_ce, u32 addr,
75 enum bam_command_type cmd, u32 data)
77 bam_prep_ce_le32(bam_ce, addr, cmd, cpu_to_le32(data));
79 #endif