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
{
38 * This enum indicates the command type in a command element
40 enum bam_command_type
{
41 BAM_WRITE_COMMAND
= 0,
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
52 * @data: actual data for write and dest addr for read in le32
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));
61 bam_ce
->mask
= cpu_to_le32(0xffffffff);
65 * bam_prep_ce - Wrapper function to prepare a single BAM command element
68 * @bam_ce: BAM command element
69 * @addr: target address
71 * @data: actual data for write and dest addr for read
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
));