From: Wen Xie Date: Thu, 14 Mar 2019 03:09:01 +0000 (+0800) Subject: sensor: adjust the log X-Git-Tag: MMI-RSA31.Q1-48-36-11~171 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=74dd9636e4d4b5d0886d73a9c7ff022b779a2f5c;p=GitHub%2FMotorolaMobilityLLC%2Fkernel-slsi.git sensor: adjust the log 1. adjust the log format 2. add log to dump adc, raw data and use filter Change-Id: I518a116e834a82fb721746ce546fe60b438bfb4f Signed-off-by: Wen Xie Reviewed-on: https://gerrit.mot.com/1320612 SLTApproved: Slta Waiver SME-Granted: SME Approvals Granted Tested-by: Jira Key Reviewed-by: Xiangpo Zhao Submit-Approved: Jira Key --- diff --git a/drivers/input/misc/sx933x.h b/drivers/input/misc/sx933x.h index c48a94584c41..faef12b1cb54 100755 --- a/drivers/input/misc/sx933x.h +++ b/drivers/input/misc/sx933x.h @@ -10,11 +10,6 @@ #include #include -#if 0 -#include -#include -#include -#endif /* * I2C Registers */ @@ -152,6 +147,11 @@ #define SX933X_OFFSETPH4_REG SX933X_AFEPHPH4_REG//bit14:0 #define SX933X_OFFSETPH5_REG SX933X_AFEPHPH5_REG//bit14:0 +#define SX933X_REG_DBG_PHASE_SEL 0x81A4 +#define SX933X_REG_PROX_ADC_MIN 0x81A8 +#define SX933X_REG_PROX_ADC_MAX 0x81AC +#define SX933X_REG_PROX_RAW 0x81B0 +#define SX933X_REG_DLT_VAR 0x81B4 //i2c register bit mask #define MSK_IRQSTAT_RESET 0x00000080 #define MSK_IRQSTAT_TOUCH 0x00000040 @@ -307,346 +307,7 @@ typedef struct totalButtonInformation *pbuttonInformation_t; * default */ /*define the value without Phase enable settings for easy changes in driver*/ -#if 0 -static const struct smtc_reg_data sx933x_i2c_reg_setup[] = -{ - //ocean disable clock spreading - { - .reg = SX933X_AFECTRL_REG, //0x4054 - .val = 0x00000400, - }, - // - { - .reg = SX933X_CLKGEN_REG, //0x4200 - .val = 0x00000008, - }, - // - { - .reg = SX933X_PINCFG_REG, //0x42C0 - .val = 0x08000000, - }, - { - .reg = SX933X_PINDOUT_REG, //0x42C4 - .val = 0x0000003F, - }, - // - { - .reg = SX933X_IRQCFG0_REG, //0x800C - .val = 0x00000000, - }, - { - .reg = SX933X_IRQCFG1_REG, //0x8010 - .val = 0x00000000, - }, - { - .reg = SX933X_IRQCFG2_REG, //0x8014 - .val = 0x00000000, - }, - { - .reg = SX933X_IRQCFG3_REG, //0x8018 - .val = 0x00000000, - }, - // - { - .reg = SX933X_SCANPERIOD_REG, //0x801C - .val = 0x00000032, - }, - { - .reg = SX933X_GNRLCTRL2_REG, //0x8020 - .val = 0x3F001F, //enable phase0~phase4 0x00FF0001, - }, - { - .reg = SX933X_AFEPARAMSPH0_REG, //0x8024 - .val = 0x300008d7, - }, - { - .reg = SX933X_AFEPHPH0_REG, //0x8028 - .val = 0x00A00BE3, - }, - { - .reg = SX933X_AFEPARAMSPH1_REG, //0x802C - .val = 0x300004D4, - }, - { - .reg = SX933X_AFEPHPH1_REG, //0x8030 - .val = 0x00, - }, - { - .reg = SX933X_AFEPARAMSPH2_REG, //0x8034 - .val = 0x300004D4,//0x44F,//AFE setting for phase2 3.85pf - }, - { - .reg = SX933X_AFEPHPH2_REG, //0x8038 - .val = 0x00,//Configure for phase2 - }, - { - .reg = SX933X_AFEPARAMSPH3_REG, //0x803C - .val = 0x300004D4,//0x44F,//AFE setting for phase3 3.3pf - }, - { - .reg = SX933X_AFEPHPH3_REG, //0x8040 - .val = 0x00,//Configure for phase3 - }, - { - .reg = SX933X_AFEPARAMSPH4_REG, //0x8044 - .val = 0x300004D4,//0x44F,//AFE setting for phase4 9.9pf - }, - { - .reg = SX933X_AFEPHPH4_REG, //0x8048 - .val = 0x00,//Configure for phase4 - }, - { - .reg = SX933X_AFEPARAMSPH5_REG, //0x804c - .val = 0x300004D4, - }, - { - .reg = SX933X_AFEPHPH5_REG, //0x8050 - .val = 0x00000000, - }, - { - .reg = SX933X_ADCFILTPH0_REG, //0x8054 - .val = 0x10162000, - }, - { - .reg = SX933X_AVGBFILTPH0_REG, //0x8058 - .val = 0x20400017, - }, - { - .reg = SX933X_AVGAFILTPH0_REG, //0x805C - .val = 0x31CF9110, - }, - { - .reg = SX933X_ADVDIG0PH0_REG, //0x8060 - .val = 0x00000000, - }, - { - .reg = SX933X_ADVDIG1PH0_REG, //0x8064 - .val = 0x00, - }, - { - .reg = SX933X_ADVDIG2PH0_REG, //0x8068 - .val = 0x00, - }, - { - .reg = SX933X_ADVDIG3PH0_REG , //0x806C - .val = 0x00000000, - }, - { - .reg = SX933X_ADVDIG4PH0_REG, //0x8070 - .val = 0x10000, - }, - { - .reg = SX933X_ADCFILTPH1_REG, //0x8074 - .val = 0x100000, - }, - { - .reg = SX933X_AVGBFILTPH1_REG, //0x8078 - .val = 0x20600C00, - }, - { - .reg = SX933X_AVGAFILTPH1_REG, //0x807C - .val = 0x00000000, - }, - { - .reg = SX933X_ADVDIG0PH1_REG, //0x8080 - .val = 0x00000000, - }, - { - .reg = SX933X_ADVDIG1PH1_REG, //0x8084 - .val = 0x00000000, - }, - { - .reg = SX933X_ADVDIG2PH1_REG, //0x8088 - .val = 0x00000000, - }, - { - .reg = SX933X_ADVDIG3PH1_REG , //0x808C - .val = 0x00000000, - }, - { - .reg = SX933X_ADVDIG4PH1_REG, //0x8090 - .val = 0x00000000, - }, - { - .reg = SX933X_ADCFILTPH2_REG, //0x8094 - .val = 0x100000, - }, - { - .reg = SX933X_AVGBFILTPH2_REG, //0x8098 - .val = 0x20600C00, - }, - { - .reg = SX933X_AVGAFILTPH2_REG, //0x809C - .val = 0x00000000, - }, - { - .reg = SX933X_ADVDIG0PH2_REG, //0x80A0 - .val = 0x00000000, - }, - { - .reg = SX933X_ADVDIG1PH2_REG, //0x80A4 - .val = 0x00000000, - }, - { - .reg = SX933X_ADVDIG2PH2_REG, //0x80A8 - .val = 0x00000000, - }, - { - .reg = SX933X_ADVDIG3PH2_REG , //0x80AC - .val = 0x00000000, - }, - { - .reg = SX933X_ADVDIG4PH2_REG, //0x80B0 - .val = 0x00000000, - }, - { - .reg = SX933X_ADCFILTPH3_REG, //0x80B4 - .val = 0x100000, - }, - { - .reg = SX933X_AVGBFILTPH3_REG, //0x80B8 - .val = 0x20600C00, - }, - { - .reg = SX933X_AVGAFILTPH3_REG, //0x80BC - .val = 0x00000000, - }, - { - .reg = SX933X_ADVDIG0PH3_REG, //0x80C0 - .val = 0x00000000, - }, - { - .reg = SX933X_ADVDIG1PH3_REG, //0x80C4 - .val = 0x00000000, - }, - { - .reg = SX933X_ADVDIG2PH3_REG, //0x80C8 - .val = 0x00000000, - }, - { - .reg = SX933X_ADVDIG3PH3_REG , //0x80CC - .val = 0x00000000, - }, - { - .reg = SX933X_ADVDIG4PH3_REG, //0x80D0 - .val = 0x00000000, - }, - { - .reg = SX933X_ADCFILTPH4_REG, //0x80D4 - .val = 0x100000, - }, - { - .reg = SX933X_AVGBFILTPH4_REG, //0x80D8 - .val = 0x20600C00, - }, - { - .reg = SX933X_AVGAFILTPH4_REG, //0x80DC - .val = 0x00000000, - }, - { - .reg = SX933X_ADVDIG0PH4_REG, //0x80E0 - .val = 0x00000000, - }, - { - .reg = SX933X_ADVDIG1PH4_REG, //0x80E4 - .val = 0x00000000, - }, - { - .reg = SX933X_ADVDIG2PH4_REG, //0x80E8 - .val = 0x00000000, - }, - { - .reg = SX933X_ADVDIG3PH4_REG , //0x80EC - .val = 0x00000000, - }, - { - .reg = SX933X_ADVDIG4PH4_REG, //0x80F0 - .val = 0x00000000, - }, - { - .reg = SX933X_ADCFILTPH5_REG, //0x80F4 - .val = 0x100000, - }, - { - .reg = SX933X_AVGBFILTPH5_REG, //0x80F8 - .val = 0x20600C00, - }, - { - .reg = SX933X_AVGAFILTPH5_REG, //0x80FC - .val = 0x00000000, - }, - { - .reg = SX933X_ADVDIG0PH5_REG, //0x8100 - .val = 0x00000000, - }, - { - .reg = SX933X_ADVDIG1PH5_REG, //0x8104 - .val = 0x00000000, - }, - { - .reg = SX933X_ADVDIG2PH5_REG, //0x8108 - .val = 0x00000000, - }, - { - .reg = SX933X_ADVDIG3PH5_REG , //0x810C - .val = 0x00000000, - }, - { - .reg = SX933X_ADVDIG4PH5_REG, //0x8110 - .val = 0x00000000, - }, - { - .reg = SX933X_REFCORRA_REG, //0x8124 - .val = 0x7B13B10, - }, - { - .reg = SX933X_REFCORRB_REG, //0x8128 - .val = 0x4000000, - }, - { - .reg = SX933X_SMARTSAR0A_REG, //0x812C - .val = 0x00000000, - }, - { - .reg = SX933X_SMARTSAR1A_REG, //0x8130 - .val = 0x00000000, - }, - { - .reg = SX933X_SMARTSAR2A_REG, //0x8134 - .val = 0x00000000, - }, - { - .reg = SX933X_SMARTSAR0B_REG, //0x8138 - .val = 0x00000000, - }, - { - .reg = SX933X_SMARTSAR1B_REG, //0x813C - .val = 0x00000000, - }, - { - .reg = SX933X_SMARTSAR2B_REG, //0x8140 - .val = 0x00000000, - }, - // - { - .reg = SX933X_AUTOFREQ0_REG, //0x8154 - .val = 0x00000000, - }, - { - .reg = SX933X_AUTOFREQ1_REG, //0x8158 - .val = 0x00000000, - }, - // - { - .reg = SX933X_HOSTIRQMSK_REG, //0x4004 - .val = 0x00000078, - }, - { - .reg = SX933X_HOSTIRQCTRL_REG, //0x4008 - .val = 0x00, - } -}; -#else + static const struct smtc_reg_data sx933x_i2c_reg_setup[] = { {0x4004,0x64}, @@ -731,10 +392,9 @@ static const struct smtc_reg_data sx933x_i2c_reg_setup[] = {0x8144,0x00}, {0x8148,0x00}, {0x814C,0x00}, - {0x81A4,0x1C40001}, + {0x81A4,0x1D40000}, }; -#define REG_PARAM_VER "21_19_2_enable_ref_adc_filter_3-0028_zero_added_ref_coef_and_thresh" -#endif + static struct _buttonInfo psmtcButtons[] = { { diff --git a/drivers/input/misc/sx933x_sar.c b/drivers/input/misc/sx933x_sar.c index 254a2ffc47a4..68ceab25a640 100755 --- a/drivers/input/misc/sx933x_sar.c +++ b/drivers/input/misc/sx933x_sar.c @@ -372,21 +372,69 @@ struct class capsense_class = { .class_groups = capsense_class_groups, }; -static void read_rawData(psx93XX_t this) -{ +static void read_dbg_raw(psx93XX_t this) { + int ph; + u32 uData, ph_sel; + s32 ant_use, ref_use, ant_raw; + s32 adc_min, adc_max, use_flt_dlt_var; + + sx933x_i2c_read_16bit(this, SX933X_REG_DBG_PHASE_SEL, &ph_sel); + sx933x_i2c_read_16bit(this, SX933X_REG_PROX_ADC_MIN, &uData); + adc_min = (s32)uData>>10; + + sx933x_i2c_read_16bit(this, SX933X_REG_PROX_ADC_MIN, &uData); + adc_max = (s32)uData>>10; + + sx933x_i2c_read_16bit(this, SX933X_REG_PROX_RAW, &uData); + ant_raw = (s32)uData>>10; + + sx933x_i2c_read_16bit(this, SX933X_REG_DLT_VAR, &uData); + use_flt_dlt_var = (s32)uData>>3; + + /* ph0 */ + if (((ph_sel >> 3) & 0x7) == 0) { + sx933x_i2c_read_16bit(this, SX933X_USEPH0_REG, &uData); + ant_use = (s32)uData>>10; + sx933x_i2c_read_16bit(this, SX933X_USEPH4_REG, &uData); + ref_use = (s32)uData>>10; + ph = 0; + } else if (((ph_sel >> 3) & 0x7) == 1) { /* ph1 */ + sx933x_i2c_read_16bit(this, SX933X_USEPH1_REG, &uData); + ant_use = (s32)uData>>10; + + sx933x_i2c_read_16bit(this, SX933X_USEPH4_REG, &uData); + ref_use = (s32)uData>>10; + ph = 1; + } else if (((ph_sel >> 3) & 0x7) == 3) { /* ph3 */ + sx933x_i2c_read_16bit(this, SX933X_USEPH3_REG, &uData); + ant_use = (s32)uData>>10; + + sx933x_i2c_read_16bit(this, SX933X_USEPH2_REG, &uData); + ref_use = (s32)uData>>10; + ph = 3; + } else { + LOG_INFO("read_dbg_raw(): invalid reg_val= 0x%X\n", ph_sel); + ph = -1; + } + + if(ph != -1) { + LOG_INFO("SMTC_DBG PH= %d USE= %d RAW= %d REF= %d MIN= %d MAX= %d DLT= %d\n", + ph, ant_use, ant_raw, ref_use, adc_min, adc_max, use_flt_dlt_var); + } +} + +static void read_rawData(psx93XX_t this) { u8 csx, index; - s32 useful; - s32 average; - s32 diff; - s32 ph2_use, ph4_use, prox_raw, dlt_var; - u32 uData, chip_state, dbg_ph_sel; + s32 useful, average, diff; + s32 ph2_use, ph4_use, ref_use; + u32 uData; u16 offset; int state; if(this) { - sx933x_i2c_read_16bit(this, SX933X_STAT0_REG, &chip_state); + sx933x_i2c_read_16bit(this, SX933X_STAT0_REG, &uData); if (debug_enable) - LOG_INFO("SX933X_STAT0_REG[0x8000] = 0x%08X\n", chip_state); + LOG_INFO("SX933X_STAT0_REG[0x8000] = 0x%08X\n", uData); sx933x_i2c_read_16bit(this, SX933X_USEPH2_REG, &uData); ph2_use = (s32)uData >> 10; @@ -394,42 +442,35 @@ static void read_rawData(psx93XX_t this) sx933x_i2c_read_16bit(this, SX933X_USEPH4_REG, &uData); ph4_use = (s32)uData >> 10; - sx933x_i2c_read_16bit(this, 0x81A4, &dbg_ph_sel); - dbg_ph_sel &= ~(7<<3); - for(csx =0; csx<5; csx++) { index = csx*4; - dbg_ph_sel &= ~(7<<3); - dbg_ph_sel |= (csx << 3); - sx933x_i2c_write_16bit(this, 0x81A4, dbg_ph_sel); - msleep(2); sx933x_i2c_read_16bit(this, SX933X_USEPH0_REG + index, &uData); useful = (s32)uData>>10; + sx933x_i2c_read_16bit(this, SX933X_AVGPH0_REG + index, &uData); average = (s32)uData>>10; + sx933x_i2c_read_16bit(this, SX933X_DIFFPH0_REG + index, &uData); diff = (s32)uData>>10; + sx933x_i2c_read_16bit(this, SX933X_OFFSETPH0_REG + index*2, &uData); offset = (u16)(uData & 0x7FFF); - sx933x_i2c_read_16bit(this, 0x81B0, &uData); - prox_raw = (s32)uData>>10; - sx933x_i2c_read_16bit(this, 0x81B4, &uData); - dlt_var = (s32)uData >> 3; + state = psmtcButtons[csx].state; + if(csx == 0 || csx == 1) { - if (debug_enable) - LOG_INFO("[PH:%d] ref_use= %d use= %d diff=%d state=%d chip_state=0x%X dlt_var=%d raw=%d avg=%d offset=%d\n", - csx, ph4_use, useful, diff, state, chip_state, dlt_var, prox_raw,average, offset); + ref_use = ph4_use; } else if(csx == 3) { - if (debug_enable) - LOG_INFO("[PH:%d] ref_use=%d use=%d diff=%d state=%d chip_state= 0x%X dlt_var=%d raw=%d avg=%d offset=%d\n", - csx, ph2_use, useful, diff, state, chip_state, dlt_var, prox_raw, average, offset); + ref_use = ph2_use; } else { - if (debug_enable) - LOG_INFO("[PH:%d] Useful=%d DIFF=%d state=%d Average=%d Offset=%d\n", - csx, useful, diff, state, average, offset); + ref_use = 0; } + if (debug_enable) + LOG_INFO("SMTC_DAT PH= %d DIFF= %d USE= %d REF= %d STATE= %d OFF=%d AVG=%d\n", + csx, diff, useful, ref_use, state, offset, average); } + if (debug_enable) + read_dbg_raw(this); } }