feat(cellular, power): enable SDM660 IPA v2.6L 4G LTE, power-key status screen, and DVFS standby
Offline project checks / check (push) Canceled after 0s
Offline project checks / check (push) Canceled after 0s
This commit is contained in:
@@ -0,0 +1,121 @@
|
||||
/* SPDX-License-Identifier: GPL-2.0-only */
|
||||
#ifndef PLATINA_IPA_V2_CMD_FORMAT_H
|
||||
#define PLATINA_IPA_V2_CMD_FORMAT_H
|
||||
|
||||
/* Wire layout from pinned platina-o-oss ipa_hw_defs.h and msm-sps.h. */
|
||||
#ifdef __KERNEL__
|
||||
#include <linux/byteorder/generic.h>
|
||||
#include <linux/errno.h>
|
||||
#include <linux/types.h>
|
||||
#else
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include <errno.h>
|
||||
typedef uint16_t u16;
|
||||
typedef uint32_t u32;
|
||||
typedef uint64_t u64;
|
||||
typedef uint16_t __le16;
|
||||
typedef uint32_t __le32;
|
||||
#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
|
||||
#define cpu_to_le16(x) ((u16)(x))
|
||||
#define cpu_to_le32(x) ((u32)(x))
|
||||
#else
|
||||
#define cpu_to_le16(x) __builtin_bswap16((u16)(x))
|
||||
#define cpu_to_le32(x) __builtin_bswap32((u32)(x))
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#define IPA_V2_REGISTER_WRITE 12
|
||||
#define IPA_V2_DMA_SHARED_MEM 19
|
||||
#define IPA_V2_BAM_IMME 0x0100
|
||||
#define IPA_V2_BAM_EOT 0x4000
|
||||
|
||||
struct ipa_v2_bam_desc {
|
||||
__le32 address;
|
||||
__le16 size;
|
||||
__le16 flags;
|
||||
};
|
||||
|
||||
struct ipa_v2_shared_mem_cmd {
|
||||
__le32 size;
|
||||
__le32 system_address;
|
||||
__le32 local_address_direction;
|
||||
__le32 reserved;
|
||||
};
|
||||
|
||||
struct ipa_v2_reg_write_cmd {
|
||||
__le32 flags_offset;
|
||||
__le32 value;
|
||||
__le32 value_mask;
|
||||
};
|
||||
|
||||
static inline bool ipa_v2_dma_range_valid(u64 address, u32 length)
|
||||
{
|
||||
return length && address <= 0xffffffffULL &&
|
||||
length - 1 <= 0xffffffffULL - address;
|
||||
}
|
||||
|
||||
static inline int ipa_v2_shared_mem_encode(struct ipa_v2_shared_mem_cmd *cmd,
|
||||
u64 address, u32 length, u32 local,
|
||||
u32 sram_size, u32 restricted,
|
||||
bool read_from_ipa, bool skip_clear)
|
||||
{
|
||||
u32 flags;
|
||||
|
||||
if (!ipa_v2_dma_range_valid(address, length) || length > 0xffff ||
|
||||
local > 0xffff || local < restricted || local > sram_size ||
|
||||
length > sram_size - local)
|
||||
return -ERANGE;
|
||||
cmd->size = cpu_to_le32(length << 16);
|
||||
cmd->system_address = cpu_to_le32(address);
|
||||
flags = local | (read_from_ipa ? (1U << 16) : 0U) |
|
||||
(skip_clear ? (1U << 17) : 0U);
|
||||
cmd->local_address_direction = cpu_to_le32(flags);
|
||||
cmd->reserved = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline int ipa_v2_shared_read_encode(struct ipa_v2_shared_mem_cmd *cmd,
|
||||
u64 address, u32 length, u32 local,
|
||||
u32 sram_size, u32 restricted)
|
||||
{
|
||||
return ipa_v2_shared_mem_encode(cmd, address, length, local, sram_size,
|
||||
restricted, true, false);
|
||||
}
|
||||
|
||||
static inline int ipa_v2_reg_write_encode(struct ipa_v2_reg_write_cmd *cmd,
|
||||
u32 offset, u32 value,
|
||||
u32 value_mask, bool skip_clear)
|
||||
{
|
||||
if (offset > 0xffff || (offset & 0x3))
|
||||
return -ERANGE;
|
||||
cmd->flags_offset = cpu_to_le32((offset << 16) |
|
||||
(skip_clear ? (1U << 15) : 0U));
|
||||
cmd->value = cpu_to_le32(value);
|
||||
cmd->value_mask = cpu_to_le32(value_mask);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline int ipa_v2_imm_cmd_desc(struct ipa_v2_bam_desc *desc,
|
||||
u64 payload_address, u32 payload_length,
|
||||
u16 opcode)
|
||||
{
|
||||
if (!ipa_v2_dma_range_valid(payload_address, payload_length))
|
||||
return -ERANGE;
|
||||
desc->address = cpu_to_le32(payload_address);
|
||||
/* The size field is the opcode, never the payload allocation length. */
|
||||
desc->size = cpu_to_le16(opcode);
|
||||
desc->flags = cpu_to_le16(IPA_V2_BAM_IMME | IPA_V2_BAM_EOT);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline int ipa_v2_shared_read_desc(struct ipa_v2_bam_desc *desc,
|
||||
u64 payload_address, u32 payload_length)
|
||||
{
|
||||
if (payload_length != sizeof(struct ipa_v2_shared_mem_cmd))
|
||||
return -ERANGE;
|
||||
return ipa_v2_imm_cmd_desc(desc, payload_address, payload_length,
|
||||
IPA_V2_DMA_SHARED_MEM);
|
||||
}
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user