#ifndef __QCOM_UBWC_H__
#define __QCOM_UBWC_H__
#include <linux/bits.h>
#include <linux/printk.h>
#include <linux/types.h>
struct qcom_ubwc_cfg_data {
u32 ubwc_enc_version;
u32 ubwc_dec_version;
u32 ubwc_swizzle;
#define UBWC_SWIZZLE_ENABLE_LVL1 BIT(0)
#define UBWC_SWIZZLE_ENABLE_LVL2 BIT(1)
#define UBWC_SWIZZLE_ENABLE_LVL3 BIT(2)
int highest_bank_bit;
bool ubwc_bank_spread;
bool macrotile_mode;
};
#define UBWC_1_0 0x10000000
#define UBWC_2_0 0x20000000
#define UBWC_3_0 0x30000000
#define UBWC_4_0 0x40000000
#define UBWC_4_3 0x40030000
#define UBWC_5_0 0x50000000
#define UBWC_6_0 0x60000000
#if IS_ENABLED(CONFIG_QCOM_UBWC_CONFIG)
const struct qcom_ubwc_cfg_data *qcom_ubwc_config_get_data(void);
#else
static inline const struct qcom_ubwc_cfg_data *qcom_ubwc_config_get_data(void)
{
return ERR_PTR(-EOPNOTSUPP);
}
#endif
static inline bool qcom_ubwc_get_ubwc_mode(const struct qcom_ubwc_cfg_data *cfg)
{
bool ret = cfg->ubwc_enc_version == UBWC_1_0;
if (ret && !(cfg->ubwc_swizzle & UBWC_SWIZZLE_ENABLE_LVL1))
pr_err("UBWC config discrepancy - level 1 swizzling disabled on UBWC 1.0\n");
return ret;
}
#endif