1 /* SPDX-License-Identifier: GPL-2.0-only */
3 * Copyright (c) 2016-2017, The Linux Foundation. All rights reserved.
6 #ifndef _QCOM_BAM_DMA_H
7 #define _QCOM_BAM_DMA_H
9 #include <asm/byteorder.h>
12 * This data type corresponds to the native Command Element
13 * supported by BAM DMA Engine.
15 * @cmd_and_addr - upper 8 bits command and lower 24 bits register address.
16 * @data - for write command: content to be written into peripheral register.
17 * for read command: dest addr to write peripheral register value.
18 * @mask - register mask.
19 * @reserved - for future usage.
22 struct bam_cmd_element {
30 * This enum indicates the command type in a command element
32 enum bam_command_type {
33 BAM_WRITE_COMMAND = 0,
38 * prep_bam_ce_le32 - Wrapper function to prepare a single BAM command
39 * element with the data already in le32 format.
41 * @bam_ce: bam command element
42 * @addr: target address
44 * @data: actual data for write and dest addr for read in le32
47 bam_prep_ce_le32(struct bam_cmd_element *bam_ce, u32 addr,
48 enum bam_command_type cmd, __le32 data)
50 bam_ce->cmd_and_addr =
51 cpu_to_le32((addr & 0xffffff) | ((cmd & 0xff) << 24));
53 bam_ce->mask = cpu_to_le32(0xffffffff);
57 * bam_prep_ce - Wrapper function to prepare a single BAM command element
60 * @bam_ce: BAM command element
61 * @addr: target address
63 * @data: actual data for write and dest addr for read
66 bam_prep_ce(struct bam_cmd_element *bam_ce, u32 addr,
67 enum bam_command_type cmd, u32 data)
69 bam_prep_ce_le32(bam_ce, addr, cmd, cpu_to_le32(data));