// SPDX-License-Identifier: (GPL-2.0-only OR BSD-3-Clause)
/*
 * Copyright (c) 2023 MediaTek Inc.
 */

#ifndef _DRV_MIU_V2_H_
#define _DRV_MIU_V2_H_

#ifdef __cplusplus
extern "C"
{
#endif

#include "MsTypes.h"
#include "UFO.h"

//-------------------------------------------------------------------------------------------------
// Defines
//-------------------------------------------------------------------------------------------------
typedef enum _eMIUIoctlCmd
{
    MDrv_CMD_MIU_Init,
    MDrv_CMD_MIU_Mask_Req_OPM_R,
    MDrv_CMD_MIU_Mask_Req_DNRB_R,
    MDrv_CMD_MIU_Mask_Req_DNRB_W,
    MDrv_CMD_MIU_Mask_Req_DNRB_RW,
    MDrv_CMD_MIU_Mask_Req_SC_RW,
    MDrv_CMD_MIU_Mask_Req_MVOP_R,
    MDrv_CMD_MIU_Mask_Req_MVD_R,
    MDrv_CMD_MIU_Mask_Req_MVD_W,
    MDrv_CMD_MIU_Mask_Req_MVD_RW,
    MDrv_CMD_MIU_Mask_Req_AUDIO_RW,
    MDrv_CMD_MIU_Mask_Req,
    MDrv_CMD_MIU_UnMask_Req,
    MDrv_CMD_MIU_GetLoading,
    MDrv_CMD_MIU_SetSsc,
    MDrv_CMD_MIU_SetSscValue,
    MDrv_CMD_MIU_Protect,
    MDrv_CMD_MIU_ProtectEx,
    MDrv_CMD_MIU_SelMIU,
    MDrv_CMD_MIU_GetProtectInfo,
    MDrv_CMD_MIU_SetGroupPriority,
    MDrv_CMD_MIU_SetHighPriority,
    MDrv_CMD_MIU_PrintProtectInfo,
    MDrv_CMD_MIU_Dram_Size,
    MDrv_CMD_MIU_ProtectAlign,
    MDrv_CMD_MIU_GetDramType,
    MDrv_CMD_MIU_IsSupportMIU1,
    MDrv_CMD_MIU_SetBWMonitor,
    MDrv_CMD_MIU_DelBWMonitor,
    MDrv_CMD_MIU_QueryBWMonitor,
    MDrv_CMD_MIU_GetBW,
    MDrv_CMD_MIU_ResetAllBWMonitor,
    MDrv_CMD_MIU_ConfigHWAttr,
    MDrv_CMD_MIU_SetClientUtilization,
    MDrv_CMD_MIU_GetClientUtilization,
    MDrv_CMD_MIU_SetClientEfficiency,
    MDrv_CMD_MIU_GetClientEfficiency,
    MDrv_CMD_MIU_SetBWValue,
    MDrv_CMD_MIU_GetBWValue,
    MDrv_CMD_MIU_GetMIUInfo,
    MDrv_CMD_MIU_GetBWAll,
    MDrv_CMD_MIU_StartBWMonitor,
    MDrv_CMD_MIU_SetCPUHPriority,
}eMIUIoctlCmd;

//-------------------------------------------------------------------------------------------------
// Macros
//-------------------------------------------------------------------------------------------------


//-------------------------------------------------------------------------------------------------
// Type and Structure Declaration
//-------------------------------------------------------------------------------------------------

//-------------------------------------------------------------------------------------------------
// Extern Global Variabls
//-------------------------------------------------------------------------------------------------

//-------------------------------------------------------------------------------------------------
// Extern Functions
//-------------------------------------------------------------------------------------------------

//////////////////////////////////////////////////////////////
// below are for utopia20 cmd and parameters structure
// for below cmds
// MDrv_CMD_MIU_Mask_Req_OPM_R,
// MDrv_CMD_MIU_Mask_Req_DNRB_R,
// MDrv_CMD_MIU_Mask_Req_DNRB_W,
// MDrv_CMD_MIU_Mask_Req_DNRB_RW,
// MDrv_CMD_MIU_Mask_Req_SC_RW,
// MDrv_CMD_MIU_Mask_Req_MVOP_R,
// MDrv_CMD_MIU_Mask_Req_MVD_R,
// MDrv_CMD_MIU_Mask_Req_MVD_W,
// MDrv_CMD_MIU_Mask_Req_MVD_RW,
// MDrv_CMD_MIU_Mask_Req_AUDIO_RW,

typedef struct _MIU_RET
{
    MS_BOOL bRet;
}MIU_RET, *PMIU_RET;

typedef struct _MIU_MASK
{
    MS_U8 u8Mask;
    MS_U8 u8Miu;
}MIU_MIU_MASK, *PMIU_MIU_MASK;

// for below cmds MDrv_CMD_MIU_Mask_Req, MDrv_CMD_MIU_UnMask_Req
typedef struct _MIU_MIUREQ_MASK
{
    MS_U8 u8Miu;
    eMIUClientID eClientID;
}MIU_MIUREQ_MASK, *PMIU_MIUREQ_MASK;

// MDrv_MIU_GetLoading,
typedef struct _MIU_GET_LOADING
{
    MS_U8 u8MiuDev;
    MS_U32 *u32Loading;
    MS_BOOL bRet;
}MIU_GET_LOADING, *PMIU_MIU_GET_LOADING;

// for below cmds MDrv_CMD_MIU_SetSsc
typedef struct _MIU_SET_SSC
{
    MS_U16 u16Fmodulation;
    MS_U16 u16FDeviation;
    MS_BOOL bEnable;
    MS_BOOL bRet;
}MIU_SET_SSC, *PMIU_SET_SSC;

// for below cmds MDrv_CMD_MIU_SetSscValue
typedef struct _MIU_SET_SSCVALUE
{
    MS_U8 u8MiuDev;
    MS_U16 u16Fmodulation;
    MS_U16 u16FDeviation;
    MS_BOOL bEnable;
    MS_BOOL bRet;
}MIU_SET_SSCVALUE, *PMIU_SET_SSCVALUE;

// for below cmds MDrv_CMD_MIU_Protect

typedef MS_U8 MIU_PROYECT_ID[16];

#ifdef BIFROST_32BIT_MODE
typedef struct DLL_PACKED _MIU_PROTECT
{
    MS_U8 u8Blockx;
    MS_U8 *pu8ProtectId;
#if defined(UFO_PUBLIC_HEADER_212)||defined(UFO_PUBLIC_HEADER_300)
    MS_U32 u32Start;
    MS_U32 u32End;
#else
    MS_U32 phy64Start;
    MS_U32 phy64End;
#endif
    MS_BOOL bSetFlag;
    MS_BOOL bRet;
}MIU_PROTECT, *PMIU_PROTECT;
#else
typedef struct DLL_PACKED _MIU_PROTECT
{
    MS_U8 u8Blockx;
    MS_U8 *pu8ProtectId;
#if defined(UFO_PUBLIC_HEADER_212)||defined(UFO_PUBLIC_HEADER_300)
    MS_U32 u32Start;
    MS_U32 u32End;
#else
    MS_PHY phy64Start;
    MS_PHY phy64End;
#endif
    MS_BOOL bSetFlag;
    MS_BOOL bRet;
}MIU_PROTECT, *PMIU_PROTECT;
#endif

// for below cmds MDrv_CMD_MIU_ProtectEx
typedef struct DLL_PACKED _MIU_PROTECTEx
{
    MS_U8 u8Blockx;
    MS_U32 *pu32ProtectId;
    MS_PHY phy64Start;
    MS_PHY phy64End;
    MS_BOOL bSetFlag;
}MIU_PROTECTEx, *PMIU_PROTECTEx;

// For HW Setting
typedef struct _MIU_ConfigHWAttr
{
    MS_U8 u8MiuDev;
    eMIU_ATTR_TYPE eAttrType;
    MS_U16 *u16Value;
    MS_U16 u16Length;
    MS_BOOL bRet;
}MIU_ConfigHWAttr, *PMIU_ConfigHWAttr;

// for below cmds MDrv_CMD_MIU_SelMIU
typedef struct _MIU_SELMIU
{
    eMIUClientID eClientID;
    eMIU_SelType eType;
    MS_BOOL bRet;
}MIU_SELMIU, *PMIU_SELMIU;

// for below cmds MDrv_CMD_MIU_GetDramType
typedef struct _MIU_GETDRAMTYPE
{
    MIU_ID eMiu;
    MIU_DDR_TYPE* pType;
}MIU_GETDRAMTYPE, *PMIU_GETDRAMTYPE;

// for below cmds MDrv_CMD_MIU_GetProtectInfo
typedef struct DLL_PACKED _MIU_GETPROTECTINFO
{
    MS_U8 u8MiuDev;
    MIU_PortectInfo *pInfo;
    MS_BOOL bRet;
}MIU_GETPROTECTINFO, *PMIU_GETPROTECTINFO;

// for below cmds MDrv_CMD_MIU_SetGroupPriority
typedef struct _MIU_SETGROUPPRIORITY
{
    MS_U8 u8MiuDev;
    MIU_GroupPriority sPriority;
    MS_BOOL bRet;
}MIU_SETGROUPPRIORITY, *PMIU_SETGROUPPRIORITY;


// for below cmds MDrv_CMD_MIU_SetHighPriority
typedef struct _MIU_SETHIGHPRIORITY
{
    MS_U8 u8MiuDev;
    eMIUClientID eClientID;
    MS_BOOL bMask;
    MS_BOOL bRet;
}MIU_SETHIGHPRIORITY, *PMIU_SETHIGHPRIORITY;

// for below cmds MDrv_CMD_MIU_Dram_Size
typedef struct _MIU_DRAM_SIZE
{
    MS_U8 u8MiuDev;
    MS_U8 DramSize;
    MS_BOOL bRet;
}MIU_DRAM_SIZE, *PMIU_DRAM_SIZE;

// for below cmds MDrv_CMD_MIU_ProtectAlign
typedef struct DLL_PACKED _MIU_PROTECT_ALIGN
{
    MS_U32 *u32PageShift;
    MS_BOOL bRet;
}MIU_PROTECT_ALIGN, *PMIU_PROTECT_ALIGN;

// for below cmds MDrv_CMD_MIU_SetBWMonitor
typedef struct DLL_PACKED _MIU_BWMONITOR
{
    MS_U8 u8MiuDev;
    MIU_BandwidthMonitorInfo *pBWInfo;
    MS_BOOL bRet;
}MIU_BWMONITOR, *PMIU_BWMONITOR;

typedef struct DLL_PACKED _MIU_BWUTILIZATION
{
    MS_U8 u8MiuDev;
    eMIUClientID eClientID;
    MS_U32 *pu32BWUtilization;
}MIU_BWUTILIZATION, *PMIU_BWUTILIZATION;

typedef struct DLL_PACKED _MIU_BWEFFICIENCY
{
    MS_U8 u8MiuDev;
    eMIUClientID eClientID;
    MS_U32 *pu32BWEfficiency;
}MIU_BWEFFICIENCY, *PMIU_BWEFFICIENCY;

typedef struct DLL_PACKED _MIU_SETGETBW
{
    MS_U32 u32ClientID;
    MIU_BW_TYPE eBWINfoType;
    MIU_UMA_Mode *peUMAMode;
    MIU_BWValue *pBWValue;
}MIU_SETGETBW, *PMIU_SETGETBW;

typedef struct DLL_PACKED _MIU_GETINFO
{
    MIU_ID eMiu;
    MIU_Info *pstMIUInfo;
}MIU_GETINFO, *PMIU_GETINFO;

typedef struct DLL_PACKED _MIU_SETCPUHPRI
{
    MIU_HPri_Scope eScope;
    MS_U64 u64Start;
    MS_U64 u64End;
    MS_BOOL bEnable;
}MIU_SETCPUHPRI, *PMIU_SETCPUHPRI;

#ifdef __cplusplus
}
#endif

#endif // _DRV_MIU_V2_H_

