blob: 8fa8880432f50864284cf2690e1a53a8a2ab68e8 [file] [log] [blame]
rjw6c1fd8f2022-11-30 14:33:01 +08001/*****************************************************************************
2* Copyright Statement:
3* --------------------
4* This software is protected by Copyright and the information contained
5* herein is confidential. The software may not be copied and the information
6* contained herein may not be used or disclosed except with the written
7* permission of MediaTek Inc. (C) 2017
8*
9* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
10* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
11* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
12* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
13* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
14* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
15* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
16* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
17* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
18* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
19* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
20* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
21*
22* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
23* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
24* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
25* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
26* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
27*
28* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
29* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
30* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
31* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
32* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
33*
34*****************************************************************************/
35
36/*******************************************************************************
37 *
38 * Filename:
39 * ---------
40 * tia.h
41 *
42 * Project:
43 * --------
44 * VMOLY
45 *
46 * Description:
47 * ------------
48 * TIA (Thermal Information Acquisition) driver internal header for MD thermal
49 *
50 * Author:
51 * -------
52 * -------
53 *
54 *============================================================================
55 * HISTORY
56 * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
57 *------------------------------------------------------------------------------
58 * removed!
59 * removed!
60 * removed!
61 *
62 * removed!
63 * removed!
64 * removed!
65 *
66 * removed!
67 * removed!
68 * removed!
69 * removed!
70 * removed!
71 * removed!
72 * removed!
73 * removed!
74 *------------------------------------------------------------------------------
75 * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
76 *============================================================================
77 ****************************************************************************/
78
79#ifndef __TIA_H__
80#define __TIA_H__
81
82#include "kal_general_types.h"
83#include "thermal_public.h"
84#include "tfwk_public.h"
85#include "ptp_public.h"
86#include "tia_public.h"
87#include "dhl_trace.h"
88#ifdef __DHL_MODULE__
89#include "tia_trace_utmd.h"
90#endif
91
92//******************************************************************************
93// tia.c
94//******************************************************************************
95// TIA sensor number, Sensor_ID (global) -> Tia_ID (local, 0~) -> Ntc_ID (physical, 0~) -> NTC (schematic, 1~)
96#define TIA_SENSOR_NUM THERMAL_TIA_SENSOR_NUM
97#define TIA_SENSOR_SID(tid) THERMAL_TIA_SENSOR_ID(tid) /* TID to SID */
98#define TIA_SENSOR_SID_VALID(sid) (((sid) >= TIA_SENSOR_SID(0)) && ((sid) <= TIA_SENSOR_SID(TIA_SENSOR_NUM-1)))
99#define TIA_SENSOR_TID(sid) ((sid) - TIA_SENSOR_SID(0)) /* SID to TID */
100#define TIA_SENSOR_TID_VALID(tid) ((tid) < TIA_SENSOR_NUM)
101extern const kal_uint32 tia_sensor_map[TIA_SENSOR_NUM];
102#define TIA_SENSOR_NID(tid) (tia_sensor_map[tid])
103
104// tia initialization
105void tia_init(void);
106
107// tia set alarm
108// @ncfg: [in] number of config list
109// @tcfgs: [in,out] pointer to tfwk_thermal_cfg_t list
110// @return: error code, refer to THERMAL_ERR_XXX @thermal_public.h
111kal_int32 tia_set_alarm(kal_uint32 ncfg, tfwk_thermal_cfg_t* tcfgs);
112
113// tia debug message
114// @tid: [in] tia id (0~)
115void tia_dbg_sns_infs(kal_uint32 tid);
116void tia_dbg_thr_cfgs(kal_uint32 tid);
117void tia_dbg_thr_mons(kal_uint32 tid);
118// tia debug control - fake adc reg
119// @en: [in] enable
120// @tid: [in] tia id (0~)
121// @ohm: [in] fake ohm
122void tia_dbg_fake_en(kal_bool en);
123void tia_dbg_fake_ohm(kal_uint32 tid, kal_uint32 ohm);
124// tia debug control - toprgu sw reset
125void tia_dbg_sw_reset(void);
126// tia debug get internal symbol
127void* tia_dbg_symbol(kal_char *sym);
128
129//******************************************************************************
130// tia_adc.c
131//******************************************************************************
132// TIA adc bit mode: 15 (default) or 12
133#define TIA_ADC_BIT_MODE 15
134
135// TIA adc to temperature range
136#define TIA_ADC_TMP_MIN (-40)
137#define TIA_ADC_TMP_MAX (125)
138#define TIA_ADC_TMP_CNT (TIA_ADC_TMP_MAX - TIA_ADC_TMP_MIN + 1)
139#define TIA_ADC_TMP_ERR 0x7FFF
140
141// TIA ADC pull-up resistor setting
142typedef enum {
143 TIA_ADC_RC_100K = 0,
144 TIA_ADC_RC_30K,
145 TIA_ADC_RC_400K,
146 TIA_ADC_RC_MAX,
147 TIA_ADC_RC_FAKE = TIA_ADC_RC_MAX
148} tia_adc_rc_type_e;
149extern const kal_uint32 tia_adc_rc2k_map[];
150#define TIA_ADC_RC2K(rc) (tia_adc_rc2k_map[rc])
151
152// tia rc_adc value to ohm
153// @rc: pull-up resistor, refer to tia_adc_rc_type_e
154// @adc: adc value
155// @return: ohm
156kal_uint32 tia_adc_to_ohm(tia_adc_rc_type_e rc, kal_uint32 adc);
157
158// tia rc_adc value to temperature in 1/10th of Celsius Degree
159// @rc: pull-up resistor, refer to tia_adc_rc_type_e
160// @adc: adc value
161// @return: temperature in 1/10th of Celsius Degree
162kal_int32 tia_adc_to_tmp(tia_adc_rc_type_e rc, kal_uint32 adc);
163
164// tia adc formula setup from pmic auxadc efuse
165void tia_adc_init(void);
166
167// tia adc debug message, auxadc efuse
168void tia_adc_dbg_efuse(kal_int32 *V18, kal_int32 *Rinb);
169
170//******************************************************************************
171// tia_atcmd.c
172//******************************************************************************
173// tia atcmd initialization
174void tia_atcmd_init(void);
175
176//******************************************************************************
177// remap to lvts interface
178//******************************************************************************
179#define TIA_LVTS_GET_TEMP(sid, tmp) lvts_get_temp(sid, tmp) // fake: ({*(tmp)=250; 0;})
180#define TIA_LVTS_GET_ALL_NUM 4
181#define TIA_LVTS_GET_ALL_TEMP(n, tmps) lvts_get_all_temp(n, tmps)
182#ifdef MT6297
183 #define TIA_LVTS_HW_RGU_RESET() tia_dbg_sw_reset()
184#else
185 #define TIA_LVTS_HW_RGU_RESET() lvts_hw_rgu_reset()
186#endif
187
188#endif