Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-only */
0002 /*
0003  * Copyright (c) 2016-2017, The Linux Foundation. All rights reserved.
0004  */
0005 
0006 #ifndef _QCOM_BAM_DMA_H
0007 #define _QCOM_BAM_DMA_H
0008 
0009 #include <asm/byteorder.h>
0010 
0011 /*
0012  * This data type corresponds to the native Command Element
0013  * supported by BAM DMA Engine.
0014  *
0015  * @cmd_and_addr - upper 8 bits command and lower 24 bits register address.
0016  * @data - for write command: content to be written into peripheral register.
0017  *     for read command: dest addr to write peripheral register value.
0018  * @mask - register mask.
0019  * @reserved - for future usage.
0020  *
0021  */
0022 struct bam_cmd_element {
0023     __le32 cmd_and_addr;
0024     __le32 data;
0025     __le32 mask;
0026     __le32 reserved;
0027 };
0028 
0029 /*
0030  * This enum indicates the command type in a command element
0031  */
0032 enum bam_command_type {
0033     BAM_WRITE_COMMAND = 0,
0034     BAM_READ_COMMAND,
0035 };
0036 
0037 /*
0038  * prep_bam_ce_le32 - Wrapper function to prepare a single BAM command
0039  * element with the data already in le32 format.
0040  *
0041  * @bam_ce: bam command element
0042  * @addr: target address
0043  * @cmd: BAM command
0044  * @data: actual data for write and dest addr for read in le32
0045  */
0046 static inline void
0047 bam_prep_ce_le32(struct bam_cmd_element *bam_ce, u32 addr,
0048          enum bam_command_type cmd, __le32 data)
0049 {
0050     bam_ce->cmd_and_addr =
0051         cpu_to_le32((addr & 0xffffff) | ((cmd & 0xff) << 24));
0052     bam_ce->data = data;
0053     bam_ce->mask = cpu_to_le32(0xffffffff);
0054 }
0055 
0056 /*
0057  * bam_prep_ce - Wrapper function to prepare a single BAM command element
0058  * with the data.
0059  *
0060  * @bam_ce: BAM command element
0061  * @addr: target address
0062  * @cmd: BAM command
0063  * @data: actual data for write and dest addr for read
0064  */
0065 static inline void
0066 bam_prep_ce(struct bam_cmd_element *bam_ce, u32 addr,
0067         enum bam_command_type cmd, u32 data)
0068 {
0069     bam_prep_ce_le32(bam_ce, addr, cmd, cpu_to_le32(data));
0070 }
0071 #endif