arm: sc8830: remove build warnings
[profile/mobile/platform/kernel/u-boot-tm1.git] / arch / arm / cpu / armv7 / sc8830 / otp-helper.c
1 /*
2  * Copyright (C) 2014 Spreadtrum Communications Inc.
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU General Public License
6  * as published by the Free Software Foundation; either version 2
7  * of the License, or (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  */
15
16 /* IMPORTANT:
17  *
18  * TODO:
19  */
20
21 #include <common.h>
22 #include <asm/arch-sc8830/otp_help.h>
23
24 #define BLK_WIDTH_OTP_EMEMORY                   ( 8 ) /* bit counts */
25 #if defined(CONFIG_SPX35L)
26 #define BLK_ADC_DETA_ABC_OTP                    ( 7 ) /* start block for ADC otp delta */
27 #else
28 #define BLK_ADC_DETA_ABC_OTP                    ( 8 ) /* start block for ADC otp delta */
29 #endif
30
31 #define BLK_ADC_DETA                    ( 7 )
32 #define BASE_ADC_P0                             711     //3.6V
33 #define BASE_ADC_P1                             830     //4.2V
34 #define VOL_P0                                  3600
35 #define VOL_P1                                  4200
36 #define ADC_DATA_OFFSET                 128
37
38 extern int __ddie_efuse_prog(int blk_index, u32 val);
39 extern u32 __adie_efuse_read(int blk_index);
40
41 u32 efuse_read(int id,int blk_index)
42 {
43         return __ddie_efuse_read(blk_index);
44 }
45 int efuse_prog(int id,int blk_index,u32 val)
46 {
47         return __ddie_efuse_prog(blk_index,val);
48
49 }
50 int sci_efuse_calibration_get(unsigned int *p_cal_data)
51 {
52         unsigned int deta;
53         unsigned short adc_temp;
54
55 #if defined(CONFIG_ADIE_SC2723) || defined(CONFIG_ADIE_SC2723S)
56         //__adie_efuse_block_dump(); /* dump a-die efuse */
57
58         /* verify to write otp data or not */
59         adc_temp = (__adie_efuse_read(0) & (1 << 7));
60         if (adc_temp)
61                 return 0;
62
63         deta = __adie_efuse_read_bits(BLK_ADC_DETA_ABC_OTP * BLK_WIDTH_OTP_EMEMORY, 16);
64 #elif defined(CONFIG_SPX30G)
65         __ddie_efuse_block_dump(); /* dump d-die efuse */
66
67         deta = __ddie_efuse_read(BLK_ADC_DETA);
68 #else
69         #warning "AuxADC CAL DETA need fixing"
70 #endif
71
72         printf("%s() get efuse block %u, deta: 0x%08x\n", __func__, BLK_ADC_DETA, deta);
73
74         deta &= 0xFFFFFF;
75
76         if ((!deta) || (p_cal_data == NULL)) {
77                 return 0;
78         }
79
80         //adc 3.6V
81         adc_temp = ((deta >> 8) & 0x00FF) + BASE_ADC_P0 - ADC_DATA_OFFSET;
82         p_cal_data[1] = (VOL_P0) | ((adc_temp << 2) << 16);
83
84         //adc 4.2V
85         adc_temp = (deta & 0x00FF) + BASE_ADC_P1 - ADC_DATA_OFFSET;
86         p_cal_data[0] = (VOL_P1) | ((adc_temp << 2) << 16);
87
88         return 1;
89 }