blob: 1aa4eeaa05d9eda5d73ac5f865f1b3b3aaa0017d [file] [log] [blame]
/*****************************************************************************
* Copyright Statement:
* --------------------
* This software is protected by Copyright and the information contained
* herein is confidential. The software may not be copied and the information
* contained herein may not be used or disclosed except with the written
* permission of MediaTek Inc. (C) 2019
*
* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
*
* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
*
* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
*
*****************************************************************************/
/*****************************************************************************
*
* Filename:
* ---------
* dcl_spmi.h
*
* Project:
* --------
* Maui_Software
*
* Description:
* ------------
* This file defines structures and functions for SPMI DCL interface.
*
* Author:
* -------
* -------
*
*============================================================================
* HISTORY
* Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
*------------------------------------------------------------------------------
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
* removed!
*
* removed!
* removed!
*
*
*------------------------------------------------------------------------------
* Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
*============================================================================
****************************************************************************/
#ifdef DCL_DEFINITION_STRUCT
#ifndef __DCL_SPMI_H_STRUCT__
#define __DCL_SPMI_H_STRUCT__
/*******************************************************************************
* DCL_OPTIONS for SPMI
*******************************************************************************/
#define SPMI_OPTIONS
/*******************************************************************************
* DCL_CONFIGURE_T
*******************************************************************************/
#define SPMI_CONFIGS
/*******************************************************************************
* DCL_EVENT for SPMI
*******************************************************************************/
#define SPMI_EVENTS
typedef enum
{
DCL_BUCK_CPU,
DCL_BUCK_GPU,
DCL_BUCK_MD,
DCL_BUCK_RF,
DCL_MAIN_PMIC,
DCL_BUCK_VPU,
DCL_SUB_PMIC,
DCL_SLV_TYPE_MAX
}SPMI_SLV_TYPE_ENUM;
/*******************************************************************************
* DCL_CTRL_DATA_T: Define the Control data structure for each module's command
*******************************************************************************/
/* For SPMI_CTRL_EXT_REGISTER_READL command. */
typedef struct
{
DCL_UINT16 type;
DCL_UINT16 addr;
DCL_UINT16 value;
DCL_UINT16 len;
}SPMI_CTRL_EXT_REGISTER_READL;
/* For SPMI_CTRL_EXT_REGISTER_WRITEL command. */
typedef struct
{
DCL_UINT16 type;
DCL_UINT16 addr;
DCL_UINT16 value;
DCL_UINT16 len;
}SPMI_CTRL_EXT_REGISTER_WRITEL;
/* For SPMI_CTRL_EXT_REGISTER_READL_FIELD command. */
typedef struct
{
DCL_UINT16 type;
DCL_UINT16 addr;
DCL_UINT16 value;
DCL_UINT16 len;
DCL_UINT16 mask;
DCL_UINT16 shift;
}SPMI_CTRL_EXT_REGISTER_READL_FIELD;
/* For SPMI_CTRL_EXT_REGISTER_WRITEL_FIELD command. */
typedef struct
{
DCL_UINT16 type;
DCL_UINT16 addr;
DCL_UINT16 value;
DCL_UINT16 len;
DCL_UINT16 mask;
DCL_UINT16 shift;
}SPMI_CTRL_EXT_REGISTER_WRITEL_FIELD;
/*******************************************************************************
* DCL_CTRL_DATA_T: Define the Control data structure for each module's command
*******************************************************************************/
#ifdef __BUILD_DOM__
/* The SPMI Command Parameter Data Structure for Each Command in DCL_CTRL_DATA_T Enum of dcl.h */
typedef struct
{
SPMI_CTRL_EXT_REGISTER_READL rSPMIExtRegisterReadL;
SPMI_CTRL_EXT_REGISTER_WRITEL rSPMIExtRegisterWriteL;
SPMI_CTRL_EXT_REGISTER_READL_FIELD rSPMIExtRegisterReadLField;
SPMI_CTRL_EXT_REGISTER_WRITEL_FIELD rSPMIExtRegisterWriteLField;
}SPMI_CTRL_DATA;
#else /* __BUILD_DOM__ */
#define SPMI_CTRLS \
SPMI_CTRL_EXT_REGISTER_READL rSPMIExtRegisterReadL; \
SPMI_CTRL_EXT_REGISTER_WRITEL rSPMIExtRegisterWriteL; \
SPMI_CTRL_EXT_REGISTER_READL_FIELD rSPMIExtRegisterReadLField; \
SPMI_CTRL_EXT_REGISTER_WRITEL_FIELD rSPMIExtRegisterWriteLField;
#endif /* __BUILD_DOM__ */
/*******************************************************************************
* DCL_CTRL_CMD for SPMI
*******************************************************************************/
#ifdef __BUILD_DOM__
typedef enum {
EXT_REGISTER_READL = 0,
EXT_REGISTER_WRITEL,
EXT_REGISTER_READL_FIELD,
EXT_REGISTER_WRITEL_FIELD,
REGISTER_READ,
REGISTER_WRITE,
EXT_REGISTER_READ,
EXT_REGISTER_WRITE,
SPMI_MOD_CMD_MAX
} SPMI_CTRL_CMD;
#else /* __BUILD_DOM__ */
#define SPMI_CMDS \
EXT_REGISTER_READL = 0, \
EXT_REGISTER_WRITEL, \
EXT_REGISTER_READL_FIELD, \
EXT_REGISTER_WRITEL_FIELD, \
REGISTER_READ, \
REGISTER_WRITE, \
EXT_REGISTER_READ, \
EXT_REGISTER_WRITE, \
SPMI_MOD_CMD_MAX,
#endif /* __BUILD_DOM__ */
#endif /*__DCL_SPMI_H_STRUCT__*/
#endif /*DCL_DEFINITION_STRUCT*/
#ifdef DCL_DEFINITION_PROTOTYPE
#ifndef __DCL_SPMI_H_PROTOTYPE__
#define __DCL_SPMI_H_PROTOTYPE__
typedef DCL_STATUS (*SPMI_CONTROL_HANDLER)(DCL_HANDLE handle, DCL_CTRL_CMD cmd, DCL_CTRL_DATA_T *data);
/*************************************************************************
* FUNCTION
* DclSPMI_Initialize
*
* DESCRIPTION
* This function is to initialize SPMI module
*
* PARAMETERS
* None
*
* RETURNS
* STATUS_OK
*
*************************************************************************/
extern DCL_STATUS DclSPMI_Initialize(void);
/*************************************************************************
* FUNCTION
* DclSPMI_Open
*
* DESCRIPTION
* This function is to open the SPMI module and return a handle
*
* PARAMETERS
* dev: only valid for DCL_SPMI
* flags: no sepcial flags is needed. Please use FLAGS_NONE
*
* RETURNS
* DCL_HANDLE_INVALID: Open failed.
* other value: a valid handle
*
*************************************************************************/
extern DCL_HANDLE DclSPMI_Open(DCL_DEV dev, DCL_FLAGS flags);
/*************************************************************************
* FUNCTION
* DclSPMI_ReadData
*
* DESCRIPTION
* This function is not supported for the SPMI module now.
*
* PARAMETERS
* N/A
*
* RETURNS
* STATUS_UNSUPPORTED
*
*************************************************************************/
extern DCL_STATUS DclSPMI_ReadData(DCL_HANDLE handle, DCL_BUFF *buff, DCL_BUFF_LEN buf_len, DCL_OPTIONS options);
/*************************************************************************
* FUNCTION
* DclSPMI_WriteData
*
* DESCRIPTION
* This function is not supported for the SPMI module now.
*
* PARAMETERS
* N/A
*
* RETURNS
* STATUS_UNSUPPORTED
*
*************************************************************************/
extern DCL_STATUS DclSPMI_WriteData(DCL_HANDLE handle, DCL_BUFF *buff, DCL_BUFF_LEN buf_len, DCL_OPTIONS options);
/*************************************************************************
* FUNCTION
* DclSPMI_Configure
*
* DESCRIPTION
* This function is not supported for the SPMI module now.
*
* PARAMETERS
* N/A
*
* RETURNS
* STATUS_UNSUPPORTED
*
*************************************************************************/
extern DCL_STATUS DclSPMI_Configure(DCL_HANDLE handle, DCL_CONFIGURE_T *configure);
/*************************************************************************
* FUNCTION
* DclSPMI_RegisterCallback
*
* DESCRIPTION
* This function is not supported for the SPMI module now.
*
* PARAMETERS
* N/A
*
* RETURNS
* STATUS_UNSUPPORTED
*
*************************************************************************/
extern DCL_STATUS DclSPMI_RegisterCallback(DCL_HANDLE handle, DCL_EVENT event, PFN_DCL_CALLBACK callback);
/*************************************************************************
* FUNCTION
* DclSPMI_Control
*
* DESCRIPTION
* This function is to send command to control the SPMI module.
*
* PARAMETERS
* handle: The handle value returned from DclSPMI_Open
* cmd: a control command for SPMI module
* RETURNS
* STATUS_OK: command is executed successfully.
* STATUS_FAIL: command is failed.
* STATUS_INVALID_CMD: It's a invalid command.
* STATUS_UNSUPPORTED: It's a unsupported command.
*
*************************************************************************/
extern DCL_STATUS DclSPMI_Control(DCL_HANDLE handle, DCL_CTRL_CMD cmd, DCL_CTRL_DATA_T *data);
/*************************************************************************
* FUNCTION
* DclSPMI_Close
*
* DESCRIPTION
* This function is to close the spmi module.
*
* PARAMETERS
* handle: the returned handle value of DclSPMI_Close
*
* RETURNS
* STATUS_OK
*
*************************************************************************/
extern DCL_STATUS DclSPMI_Close(DCL_HANDLE handle);
#endif /*__DCL_SPMI_H_PROTOTYPE__*/
#endif //DCL_DEFINITION_PROTOTYPE