lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 1 | /*******************************************************************************
|
| 2 | * Copyright (C) 2014, ZTE Corporation.
|
| 3 | *
|
| 4 | * File Name:
|
| 5 | * File Mark:
|
| 6 | * Description:
|
| 7 | * Others:
|
| 8 | * Version: v1.0
|
| 9 | * Author:
|
| 10 | * Date: 2015-09-11
|
| 11 | * History 1:
|
| 12 | * Date:
|
| 13 | * Version:
|
| 14 | * Author:
|
| 15 | * Modification:
|
| 16 | * History 2:
|
| 17 | ********************************************************************************/
|
| 18 |
|
| 19 | #ifndef _DRVS_TSC_H
|
| 20 | #define _DRVS_TSC_H
|
| 21 |
|
| 22 | /****************************************************************************
|
| 23 | * Include files
|
| 24 | ****************************************************************************/
|
| 25 | #include "ram_config.h"
|
| 26 |
|
| 27 | /****************************************************************************
|
| 28 | * Types
|
| 29 | ****************************************************************************/
|
| 30 | typedef enum _T_TsCtrl_Probe
|
| 31 | {
|
| 32 | PROBE_ADC1 = 0,
|
| 33 | PROBE_ADC2,
|
| 34 | PROBE_RESEV1,
|
| 35 | PROBE_RESEV2,
|
| 36 | PROBE_RESEV3,
|
| 37 | PROBE_RESEV4,
|
| 38 | PROBE_MAX,
|
| 39 | } Ts_TsCtrl_Probe;
|
| 40 |
|
| 41 | typedef enum _T_Ts_Temp_interregional
|
| 42 | {
|
| 43 | TS_TEMP_INTERVAL_T0 = 0,
|
| 44 | TS_TEMP_INTERVAL_T1,
|
| 45 | TS_TEMP_INTERVAL_T2,
|
| 46 | TS_TEMP_INTERVAL_T3,
|
| 47 | TS_TEMP_INTERVAL_T4,
|
| 48 | TS_TEMP_INTERVAL_T5,
|
| 49 | TS_TEMP_INTERVAL_T6,
|
| 50 | TS_TEMP_INTERVAL_T7,
|
| 51 | TS_TEMP_INTERVAL_MAX
|
| 52 | }Ts_Temp_interregional;
|
| 53 | typedef enum
|
| 54 | {
|
| 55 | TS_TEMP_VALUE_TABLE_NUMBER = 0,
|
| 56 | TS_TEMP_VOLTAGE_TABLE_NUMBER = 1,
|
| 57 | TS_TEMP_TABLE_NUMBER_MAX
|
| 58 | }TS_TEMP_TABLE_NUMBER;
|
| 59 |
|
| 60 | typedef enum _T_Ts_Member
|
| 61 | {
|
| 62 | TS_MEMBER_PROBE = 0,
|
| 63 | TS_MEMBER_TEMP,
|
| 64 |
|
| 65 | TS_MEMBER_MAX,
|
| 66 | } Ts_Member;
|
| 67 |
|
| 68 |
|
| 69 | typedef enum _T_TsCtrl_Strategy_Id
|
| 70 | {
|
| 71 | PS_STRATEGY_RATE = 0,
|
| 72 | PS_STRATEGY_ANYRESIDENT,
|
| 73 | WIFI_STRATEGY,
|
| 74 | CHARGER_STRATEGY,
|
| 75 | AP_RATE,
|
| 76 | MAX_TSCTRL_STRATEGY_ID
|
| 77 | } T_TsCtrl_Strategy_ModuleId;
|
| 78 |
|
| 79 | /**************************************************
|
| 80 | 0--STRTEGY_STOP: ֹͣ
|
| 81 | 1--STRTEGY_START: ¿ªÊ¼
|
| 82 | 2--STRTEGY_HOLD: HOLD֮ǰ²ßÂÔ
|
| 83 | **************************************************/
|
| 84 | typedef enum _T_TsCtrl_Strategy
|
| 85 | {
|
| 86 | STRTEGY_STOP = 0,
|
| 87 | STRTEGY_START=1,
|
| 88 | STRTEGY_HOLD=2,
|
| 89 |
|
| 90 | STRTEGY_MAX,
|
| 91 | } Ts_TsCtrlStrategy;
|
| 92 | /****************************************************************************
|
| 93 | * Global Function Prototypes
|
| 94 | ****************************************************************************/
|
| 95 | typedef struct _T_ZDrvTsc_Opt
|
| 96 | {
|
| 97 | VOID (*tsc_RefGetAdcvalue)(SINT32 adcValue, UINT32 *temp);
|
| 98 | VOID (*tsc_RefSetProbeStr)(UINT32 probe_num,UINT32 temperature );
|
| 99 | VOID (*tsc_RefStrategyDispatch)(VOID);
|
| 100 |
|
| 101 | }T_ZDrvTsc_Opt;
|
| 102 | /****************************************************************************
|
| 103 | * macro define
|
| 104 | ****************************************************************************/
|
| 105 | #define tsc_SetRegBit(regName, bitAddr, bitValue) \
|
| 106 | do{ \
|
| 107 | if(bitValue == TRUE) \
|
| 108 | reg32(regName) |= (0x1<<bitAddr); \
|
| 109 | else \
|
| 110 | reg32(regName) &= ~(0x1<<bitAddr); \
|
| 111 | }while(0)
|
| 112 |
|
| 113 | #define tsc_SetRegBits(regName, bitsAddr, bitsLen, bitsValue) \
|
| 114 | do{ \
|
| 115 | reg32(regName) = (reg32(regName)&(~(((0x1<<bitsLen)-0x1)<<bitsAddr)))|(bitsValue<<bitsAddr);\
|
| 116 | }while(0)
|
| 117 |
|
| 118 |
|
| 119 | /**/
|
| 120 | #define STRATEGY_PHY_NUM 8
|
| 121 | #define BITS_FOR_PHYIRAM 1
|
| 122 | /*TSCTRL_PHY iram ÿһbit±íʾPHYµÄÒ»¸ö²ßÂÔÊÇ·ñÖ´ÐÐ*/
|
| 123 | #define BIT_LIMIT_LTE_DOWNRATE1 0
|
| 124 | #define BIT_LIMIT_LTE_DOWNRATE2 1
|
| 125 | #define BIT_LIMIT_W_DOWNRATE1 2
|
| 126 | #define BIT_LIMIT_W_DOWNRATE2 3
|
| 127 | #define BIT_LIMIT_LTE_UPTRANSIMITPOWER1 4
|
| 128 | #define BIT_LIMIT_LTE_UPTRANSIMITPOWER2 5
|
| 129 | #define BIT_LIMIT_W_UPTRANSIMITPOWER1 6
|
| 130 | #define BIT_LIMIT_W_UPTRANSIMITPOWER2 7
|
| 131 | /**/
|
| 132 | //#define STRATEGY_PS_NUM 2
|
| 133 | #define BITS_FOR_PSIRAM 4
|
| 134 | /*TSCTRL_PS iram ÿËÄbit±íʾPSµÄÒ»¸ö²ßÂÔÊÇ·ñÖ´ÐÐ*/
|
| 135 | #define BIT_PS_RATE 0
|
| 136 | #define BIT_PS_ANYRESIDENT 4
|
| 137 | #define BIT_SHUTDOWN 8
|
| 138 | /**/
|
| 139 | //#define STRATEGY_PERIP_NUM 2
|
| 140 | #define BITS_FOR_PEPIPIRAM 4
|
| 141 | /*TSCTRL_PERIP iram ÿËÄbit±íʾTSCTRL_PERIPµÄÒ»¸ö²ßÂÔÊÇ·ñÖ´ÐÐ*/
|
| 142 | #define BIT_WIFI 0
|
| 143 | #define BIT_CHHRGER 4
|
| 144 | #define BIT_APRATE 8
|
| 145 |
|
| 146 | /**/
|
| 147 | //#define STRATEGY_AP_NUM 2
|
| 148 | #define BITS_FOR_APPIRAM 4
|
| 149 | /*TSCTRL_AP iram ÿËÄbit±íʾAPµÄÒ»¸ö²ßÂÔÊÇ·ñÖ´ÐÐ*/
|
| 150 |
|
| 151 |
|
| 152 | /*TSCTRL_PHY iramInfo:ÿһbit±íʾPHYµÄÒ»¸ö²ßÂÔÊÇ·ñÖ´ÐÐ
|
| 153 | bit0:limit_ltedownrate1 1:ÏÞÖÆlteÏÂÐÐËÙÂÊ1£»0:Í£Ö¹ÏÞÖÆlteÏÂÐÐËÙÂÊ1
|
| 154 | bit1:limit_ltedownrate2 1:ÏÞÖÆlteÏÂÐÐËÙÂÊ2£»0:Í£Ö¹ÏÞÖÆlteÏÂÐÐËÙÂÊ2
|
| 155 | bit2:limit_wdownrate1 1:ÏÞÖÆwÏÂÐÐËÙÂÊ1£»0:Í£Ö¹ÏÞÖÆwÏÂÐÐËÙÂÊ1
|
| 156 | bit3:limit_wdownrate2 1:ÏÞÖÆwÏÂÐÐËÙÂÊ2£»0:Í£Ö¹ÏÞÖÆwÏÂÐÐËÙÂÊ2
|
| 157 | bit4:limit_lteuptransmitrate1 1:ÏÞÖÆlteÉÏÐз¢É书ÂÊ1£»0:Í£Ö¹ÏÞÖÆlteÉÏÐз¢É书ÂÊ1
|
| 158 | bit5:limit_lteuptransmitrate2 1:ÏÞÖÆlteÉÏÐз¢É书ÂÊ2£»0:Í£Ö¹ÏÞÖÆlteÉÏÐз¢É书ÂÊ2
|
| 159 | bit6:limit_wuptransmitrate1 1:ÏÞÖÆwÉÏÐз¢É书ÂÊ1£»0:Í£Ö¹ÏÞÖÆwÉÏÐз¢É书ÂÊ1
|
| 160 | bit7:limit_wuptransmitrate2 1:ÏÞÖÆwÉÏÐз¢É书ÂÊ2£»0:Í£Ö¹ÏÞÖÆwÉÏÐз¢É书ÂÊ2
|
| 161 | */
|
| 162 | #define TSCTRL_PHY (IRAM_BASE_ADDR_TPC+0x00)/* 1K£IRAM_BASE_ADDR_TPC++0x400--¬Â¿ØÊý¾Ý´æ·Å */
|
| 163 |
|
| 164 | /*TSCTRL_PHY+0x04--TSCTRL_PHY+0x44
|
| 165 | ÿ4 bit±íʾÿ¸ö̽²âµãÊÇ·ñÐèÒªÖ´ÐвßÂÔ1:Ö´ÐÐ0:²»Ö´ÐÐ;2 HOLD*/
|
| 166 | #define TSCTRL_PS (TSCTRL_PHY+0x04)
|
| 167 | #define TSCTRL_AP (TSCTRL_PHY+0x08)
|
| 168 | #define TSCTRL_PERIP (TSCTRL_PHY+0x0C)
|
| 169 |
|
| 170 | /*ÿ4 bit±íʾÿ¸ö̽²âµãÊÇ·ñÐèÒªÖ´ÐвßÂÔ1:Ö´ÐÐ0:²»Ö´ÐÐ;2 HOLD*/
|
| 171 | #define TSCTRL_LIMIT_LTE_DOWNRATE1 (TSCTRL_PHY+0x10) /*²ßÂÔA*/
|
| 172 | #define TSCTRL_LIMIT_LTE_DOWNRATE2 (TSCTRL_PHY+0x14) /*²ßÂÔB*/
|
| 173 | #define TSCTRL_LIMIT_W_DOWNRATE1 (TSCTRL_PHY+0x18) /*²ßÂÔA*/
|
| 174 | #define TSCTRL_LIMIT_W_DOWNRATE2 (TSCTRL_PHY+0x1c) /*²ßÂÔB*/
|
| 175 | #define TSCTRL_LIMIT_LTE_UPTRANSIMITPOWER1 (TSCTRL_PHY+0x20) /*²ßÂÔC*/
|
| 176 | #define TSCTRL_LIMIT_LTE_UPTRANSIMITPOWER2 (TSCTRL_PHY+0x24) /*²ßÂÔD*/
|
| 177 | #define TSCTRL_LIMIT_W_UPTRANSIMITPOWER1 (TSCTRL_PHY+0x28) /*²ßÂÔC*/
|
| 178 | #define TSCTRL_LIMIT_W_UPTRANSIMITPOWER2 (TSCTRL_PHY+0x2c) /*²ßÂÔD*/
|
| 179 | #define TSCTRL_PS_RATE (TSCTRL_PHY+0x30) /*²ßÂÔE*/
|
| 180 | #define TSCTRL_PS_ANYRESIDENT (TSCTRL_PHY+0x34) /*²ßÂÔF*/
|
| 181 | #define TSCTRL_SHUTDOWN (TSCTRL_PHY+0x38) /*²ßÂÔG*/
|
| 182 | #define TSCTRL_WIFI (TSCTRL_PHY+0x3c) /*²ßÂÔF*/
|
| 183 | #define TSCTRL_CHARGER (TSCTRL_PHY+0x40) /*²ßÂÔF*/
|
| 184 | #define TSCTRL_APRATE (TSCTRL_PHY+0x44) /*²ßÂÔF*/
|
| 185 | #define TSCTRL_DFS (TSCTRL_PHY+0x48) /*²ßÂÔDFS*/
|
| 186 |
|
| 187 | /*ÿ¸ö̽Õë¶Ô²ßÂԵĿª¹ØÐÅÏ¢ÔÚ´æ´¢²ßÂÔIRAMµÄÆðʼbitλ*/
|
| 188 | #define BITS_FOR_PROBES 4
|
| 189 | #define BIT_PROBE_ADC1 (PROBE_ADC1*BITS_FOR_PROBES)
|
| 190 | #define BIT_PROBE_ADC2 (PROBE_ADC2*BITS_FOR_PROBES)
|
| 191 | #define BIT_PROBE_RESEV1 (PROBE_RESEV1*BITS_FOR_PROBES)
|
| 192 | #define BIT_PROBE_RESEV2 (PROBE_RESEV2*BITS_FOR_PROBES)
|
| 193 | #define BIT_PROBE_RESEV3 (PROBE_RESEV3*BITS_FOR_PROBES)
|
| 194 | #define BIT_PROBE_RESEV (PROBE_RESEV4*BITS_FOR_PROBES)
|
| 195 |
|
| 196 |
|
| 197 | /*Ô¤Áô²¿·Ö¿Õ¼äÓÃÀ´´æ´¢ÐèÒªR7´«µÝµ½A9µÄÐÅÏ¢,TSCTRL_PHY+0x100--TSCTRL_PHY+0x400*/
|
| 198 | #define TSCTRL_TEMPADC1 (TSCTRL_PHY+0x100) /*temp adc1*/
|
| 199 | #define TSCTRL_TEMPADC2 (TSCTRL_PHY+0x104) /*temp adc2*/
|
| 200 | #define TSCTRL_TEMPREV1 (TSCTRL_PHY+0x108) /*temp rev1*/
|
| 201 | #define TSCTRL_TEMPREV2 (TSCTRL_PHY+0x10c) /*temp rev2*/
|
| 202 | #define TSCTRL_TEMPREV3 (TSCTRL_PHY+0x110) /*temp rev3*/
|
| 203 | #define TSCTRL_TEMPREV4 (TSCTRL_PHY+0x114) /*temp rev3*/
|
| 204 | #define TSCTRL_DETECT_EN (TSCTRL_PHY+0x118) /*TsNvData.DetectEn*/
|
| 205 | #define TSCTRL_TEMP_PERCENT (TSCTRL_PHY+0x11c) /*APrate ,g_tempPercent*/
|
| 206 |
|
| 207 | /**/
|
| 208 | #define PROBE_NUM PROBE_MAX
|
| 209 | #define PROBE_INFO 2 //fixed value, probe num and temp
|
| 210 | #define TS_ADC_TEMP_NUMBER 2
|
| 211 | #define TS_ADC_TEMP_VOLTAGE_NUMBER 110
|
| 212 | #define TS_TEMP_NUMBER_SMALLEST 0
|
| 213 | #define TS_TEMP_NUMBER_BIGGEST 96
|
| 214 |
|
| 215 | #define TSC_DEBUG_DEF
|
| 216 |
|
| 217 | #ifdef TSC_DEBUG_DEF
|
| 218 | #define TSC_DEBUG(s...) zOss_Printf(1,1, ##s) /*ramlog_Printf(RAMLOG_MOD_CHARGER, ##s)*/
|
| 219 | #else
|
| 220 | #define TSC_DEBUG(s...)
|
| 221 | #endif
|
| 222 | /****************************************************************************
|
| 223 | * fuction extern
|
| 224 | ****************************************************************************/
|
| 225 |
|
| 226 | typedef VOID (* T_TsCtrl_CallbackFunction)( UINT8 en ); /*en: 1,Æô¶¯²ßÂÔ£¬0,Í£Ö¹²ßÂÔ; 2: hold ²ßÂÔ*/
|
| 227 | SINT32 zDrvTsc_SetOpt(T_ZDrvTsc_Opt* pTscOpt);
|
| 228 |
|
| 229 | extern SINT32 zDrvTsCtrl_RegCallback(T_TsCtrl_Strategy_ModuleId module,T_TsCtrl_CallbackFunction callback);
|
| 230 | extern SINT32 zDrvTsc_SetTscEn(UINT8 val); //val:0xB2,οشò¿ª£» ÆäËûֵοعرÕ
|
| 231 | extern SINT32 zDrvTsc_GetTscEn(VOID);
|
| 232 | VOID zDrvTsc_GetTscTempPercent(UINT32 *percent);
|
| 233 | //UINT32 *zDrvTsc_GetTscDbbProbTemp(void);
|
| 234 | #endif
|
| 235 |
|