blob: adca82162003a5b68e74246cd4e4e4b6608e94af [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_task.c
41 *
42 * Project:
43 * --------
44 * VMOLY
45 *
46 * Description:
47 * ------------
48 * TIA (Thermal Information Acquisition) driver - task
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 * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
63 *============================================================================
64 ****************************************************************************/
65
66#include "kal_public_api.h"
67#include "syscomp_config.h"
68#include "task_config.h"
69#include "tia.h"
70
71#ifndef NVRAM_NOT_PRESENT
72#include "thermal_nvram_def.h"
73#include "nvram_interface.h"
74#if NVRAM_EF_THERMAL_SENSOR_INFO_TOTAL != THERMAL_TOTAL_SENSOR_NUM
75 #error "NVRAM_EF_THERMAL_SENSOR_INFO_TOTAL != THERMAL_TOTAL_SENSOR_NUM"
76#endif
77extern nvram_ltable_entry_struct logical_data_item_table_thermal[];
78
79kal_bool tia_nvram_read_sensor_info(kal_uint32 sensor_id, nvram_thermal_sensor_info_struct *info)
80{
81 kal_uint16 rid = sensor_id + 1; // record_id from 1, sensor_id from 0
82
83 return nvram_external_read_data(NVRAM_EF_THERMAL_SENSOR_INFO_LID, rid,
84 (kal_uint8 *) info, sizeof(nvram_thermal_sensor_info_struct));
85}
86#endif //NVRAM_NOT_PRESENT
87
88static kal_eventgrpid tia_event_grp;
89
90static kal_bool tia_task_init(void)
91{
92 #ifndef NVRAM_NOT_PRESENT
93 nvram_ltable_register(logical_data_item_table_thermal);
94 #endif
95
96 tia_event_grp = kal_create_event_group("TIA_EVENT");
97
98 lvts_task_init();
99
100 tia_init();
101 tia_atcmd_init();
102
103 return KAL_TRUE;
104}
105
106static void tia_task_main(task_entry_struct *task_entry_ptr)
107{
108 kal_uint32 evt;
109
110 while (1) {
111 kal_retrieve_eg_events(tia_event_grp, 0xffffffff, KAL_OR_CONSUME, &evt, KAL_SUSPEND);
112 #if defined(MT6297) && defined(__MTK_INTERNAL__)
113 ASSERT(0);
114 #else
115 DEBUG_ASSERT(0);
116 #endif
117 }
118}
119
120kal_bool tia_create(comptask_handler_struct **handle)
121{
122 static const comptask_handler_struct tia_task_info = {
123 tia_task_main, /* task entry function */
124 tia_task_init, /* task initialization function */
125 NULL, /* task reset handler */
126 };
127 *handle = (comptask_handler_struct *)&tia_task_info;
128 return KAL_TRUE; /*always return true here*/
129}