]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blob - include/linux/dma/qcom_bam_dma.h
ACPI: fix acpi_find_child_device() invocation in acpi_preset_companion()
[mirror_ubuntu-bionic-kernel.git] / include / linux / dma / qcom_bam_dma.h
1 /*
2 * Copyright (c) 2016-2017, The Linux Foundation. All rights reserved.
3 *
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.
7 *
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.
12 */
13
14 #ifndef _QCOM_BAM_DMA_H
15 #define _QCOM_BAM_DMA_H
16
17 #include <asm/byteorder.h>
18
19 /*
20 * This data type corresponds to the native Command Element
21 * supported by BAM DMA Engine.
22 *
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.
28 *
29 */
30 struct bam_cmd_element {
31 __le32 cmd_and_addr;
32 __le32 data;
33 __le32 mask;
34 __le32 reserved;
35 };
36
37 /*
38 * This enum indicates the command type in a command element
39 */
40 enum bam_command_type {
41 BAM_WRITE_COMMAND = 0,
42 BAM_READ_COMMAND,
43 };
44
45 /*
46 * prep_bam_ce_le32 - Wrapper function to prepare a single BAM command
47 * element with the data already in le32 format.
48 *
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
53 */
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)
57 {
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);
62 }
63
64 /*
65 * bam_prep_ce - Wrapper function to prepare a single BAM command element
66 * with the data.
67 *
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
72 */
73 static inline void
74 bam_prep_ce(struct bam_cmd_element *bam_ce, u32 addr,
75 enum bam_command_type cmd, u32 data)
76 {
77 bam_prep_ce_le32(bam_ce, addr, cmd, cpu_to_le32(data));
78 }
79 #endif