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 u32 efuse_read(int id,int blk_index)
40 return __ddie_efuse_read(blk_index);
42 int efuse_prog(int id,int blk_index,u32 val)
44 return __ddie_efuse_prog(blk_index,val);
47 int sci_efuse_calibration_get(unsigned int *p_cal_data)
50 unsigned short adc_temp;
52 #if defined(CONFIG_ADIE_SC2723) || defined(CONFIG_ADIE_SC2723S)
53 //__adie_efuse_block_dump(); /* dump a-die efuse */
55 /* verify to write otp data or not */
56 adc_temp = (__adie_efuse_read(0) & (1 << 7));
60 deta = __adie_efuse_read_bits(BLK_ADC_DETA_ABC_OTP * BLK_WIDTH_OTP_EMEMORY, 16);
61 #elif defined(CONFIG_SPX30G)
62 __ddie_efuse_block_dump(); /* dump d-die efuse */
64 deta = __ddie_efuse_read(BLK_ADC_DETA);
66 #warning "AuxADC CAL DETA need fixing"
69 printf("%s() get efuse block %u, deta: 0x%08x\n", __func__, BLK_ADC_DETA, deta);
73 if ((!deta) || (p_cal_data == NULL)) {
78 adc_temp = ((deta >> 8) & 0x00FF) + BASE_ADC_P0 - ADC_DATA_OFFSET;
79 p_cal_data[1] = (VOL_P0) | ((adc_temp << 2) << 16);
82 adc_temp = (deta & 0x00FF) + BASE_ADC_P1 - ADC_DATA_OFFSET;
83 p_cal_data[0] = (VOL_P1) | ((adc_temp << 2) << 16);