2 * Copyright (C) 2014 Spreadtrum Communications Inc.
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.
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.
22 #include <asm/arch-sc8830/otp_help.h>
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 */
28 #define BLK_ADC_DETA_ABC_OTP ( 8 ) /* start block for ADC otp delta */
31 #define BLK_ADC_DETA ( 7 )
32 #define BASE_ADC_P0 711 //3.6V
33 #define BASE_ADC_P1 830 //4.2V
36 #define ADC_DATA_OFFSET 128
38 extern int __ddie_efuse_prog(int blk_index, u32 val);
39 extern u32 __adie_efuse_read(int blk_index);
41 u32 efuse_read(int id,int blk_index)
43 return __ddie_efuse_read(blk_index);
45 int efuse_prog(int id,int blk_index,u32 val)
47 return __ddie_efuse_prog(blk_index,val);
50 int sci_efuse_calibration_get(unsigned int *p_cal_data)
53 unsigned short adc_temp;
55 #if defined(CONFIG_ADIE_SC2723) || defined(CONFIG_ADIE_SC2723S)
56 //__adie_efuse_block_dump(); /* dump a-die efuse */
58 /* verify to write otp data or not */
59 adc_temp = (__adie_efuse_read(0) & (1 << 7));
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 */
67 deta = __ddie_efuse_read(BLK_ADC_DETA);
69 #warning "AuxADC CAL DETA need fixing"
72 printf("%s() get efuse block %u, deta: 0x%08x\n", __func__, BLK_ADC_DETA, deta);
76 if ((!deta) || (p_cal_data == NULL)) {
81 adc_temp = ((deta >> 8) & 0x00FF) + BASE_ADC_P0 - ADC_DATA_OFFSET;
82 p_cal_data[1] = (VOL_P0) | ((adc_temp << 2) << 16);
85 adc_temp = (deta & 0x00FF) + BASE_ADC_P1 - ADC_DATA_OFFSET;
86 p_cal_data[0] = (VOL_P1) | ((adc_temp << 2) << 16);