blob: a839347182aeeff0f13b734e4800c368ff4f6d30 [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) 2017
*
* 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:
* ---------
* tfwk_public.h
*
* Project:
* --------
* VMOLY
*
* Description:
* ------------
* Thermal Framework public interface
*
* Author:
* -------
*
*
*============================================================================
* HISTORY
* Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
*------------------------------------------------------------------------------
* removed!
* removed!
* removed!
*------------------------------------------------------------------------------
* Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
*============================================================================
****************************************************************************/
#ifndef __TFWK_PUBLIC_H__
#define __TFWK_PUBLIC_H__
#include "kal_general_types.h"
#include "thermal_public.h"
/*=============================================================
* TFWK enums
*=============================================================*/
// enum for sensor type
typedef enum{
TFWK_LVTS = 0,
TFWK_TIA = 1,
MAX_SENSOR_TYPE
} tfwk_mtk_stype_e;
/*=============================================================
* Error code
*=============================================================*/
#define TFWK_NO_FAILURE 0x00000000
#define TFWK_FAILURE 0x00000002
#define TFWK_ALARM_ID_NOT_SUPPORT 0x00000839
#define TFWK_SENSOR_ID_NOT_SUPPORT 0x0000083C
#define TFWK_THERSHOLD_OUT_OF_RANGE 0x0000083A
/*=============================================================
* TFWK structures
*=============================================================*/
// structure for threshold setting
typedef struct{
kal_uint32 enable;
kal_uint32 sensor_id;
kal_uint32 alarm_id;
kal_int32 threshold_value;
kal_uint32 hysteresis_value;
kal_uint32 sampling_period;
kal_uint32 sensor_alarm_type;
} tfwk_thermal_cfg_t;
// stucture for thermal sensor info
typedef struct{
kal_uint32 sensor_id;
kal_int32 min_temperature;
kal_uint32 max_temperature;
kal_int32 warning_temperature;
kal_uint32 accuracy;
kal_uint32 resolution;
kal_uint8 sensor_name[40];
} tfwk_sensor_info_t;
typedef kal_int32(*s_get_temp_fp)(kal_uint32 sensor_id, kal_int32 *temp);
typedef kal_int32(*s_set_alarm_fp)(kal_uint32 ncfg, tfwk_thermal_cfg_t* tcfgs);
typedef struct{
s_get_temp_fp get_temp_fp;
s_set_alarm_fp set_alarm_fp;
} tfwk_sensor_if_t;
/**
* @function tfwk_init
* @brief TFWK initialize
*/
extern void tfwk_init(void);
/**
* @function tfwk_sensor_reg
* @brief API for driver regist TFWK before OS scheduling
*
* @param s_type driver sensor type
* @param n_sensor driver sensor number
* @param sensors driver sensor information
* @param sensor_if driver's callback function
*/
extern void tfwk_sensor_reg(tfwk_mtk_stype_e s_type, kal_uint32 n_sensor, tfwk_sensor_info_t* sensors, tfwk_sensor_if_t* sensor_if);
/**
* @function tfwk_sensor_notify
* @brief API for driver ,notify MSG_ID: <MSG_ID_L5_THERMAL_STATE_INFO>, DO NOT PRINT LOG!
* @param sta_info sta_info pointer
*
* @return TFWK_NO_FAILURE ==> success
*/
extern kal_int32 tfwk_sensor_notify(thermal_sta_info_t* sta_info);
/**
* @function tfwk_get_sensor_num
* @brief API for L5 querying sensor number
*
* @return total number of accessible sensors
*/
extern kal_uint32 tfwk_get_sensor_num(void);
/**
* @function tfwk_get_sensor_info
* @brief API for L5 querying sensorID info
* @param sid sensor id
* @param sinfo sensor info pointer
*
* @return TFWK_NO_FAILURE ==> success
* TFWK_FAILURE ==> (sinfo pointer == NULL)
* TFWK_SENSOR_ID_NOT_SUPPORT ==> query invalid sensor id
*/
extern kal_uint32 tfwk_get_sensor_info (kal_uint32 sid, tfwk_sensor_info_t* sinfo);
/**
* @function tfwk_set_sensor_cfg
* @brief API for L5 config sensor setting, pick LVTS error to return while both driver return error
* @param ncfg config number
* @param tcfgs config pointer
*
* @return TFWK_NO_FAILURE ==> success
* TFWK_FAILURE ==> (invalid config number) or (driver's callback func == NULL) or (tcfgs pointer == NULL)
* LVTS error code ==> pick LVTS error to return while both driver return error
* TIA error code ==> TIA return error
*/
extern kal_uint32 tfwk_set_sensor_cfg(kal_uint32 ncfg, tfwk_thermal_cfg_t* tcfgs);
/**
* @function tfwk_get_sensor_state
* @brief API for L5 querying sensor temperature.
* @param sid query sensor id.
* @param temp temperature pointer.
*
* @return TFWK_NO_FAILURE ==> success
* TFWK_SENSOR_ID_NOT_SUPPORT ==> query invalid sensor id
* TFWK_FAILURE ==> (temperature pointer == NULL) or (driver's callback func == NULL)
*/
extern kal_uint32 tfwk_get_sensor_state(kal_uint32 sid, kal_int32* temp);
/**
* @function tfwk_atcmd_public
* @brief API for tfwk public atcmd handler
* @data_len: atcmd data length
* @data_str: atcmd byte array pointer
* @return KAL_TRUE: success, KAL_FALSE: fail
*/
extern kal_bool tfwk_atcmd_public(kal_uint32 data_len, kal_uint8 *data_str);
#endif