EKKANE-372:Modify for Capsensor params
authoryanfei <yanfei5@huaqin.com>
Fri, 28 Dec 2018 09:33:08 +0000 (17:33 +0800)
committerlingsen1 <lingsen1@lenovo.com>
Sun, 7 Feb 2021 09:36:45 +0000 (17:36 +0800)
Modify for Capsensor params

Change-Id: I6cec5ca8af4ea6caa394286b0c3e97a0060de3a0
Signed-off-by: yanfei <yanfei5@huaqin.com>
arch/arm64/boot/dts/exynos/wing-sensor.dtsi
drivers/input/misc/sx933x.h
drivers/input/misc/sx933x_sar.c

index c3df88356d78e27c1c9e3fb7e2af1805409d7c9f..af09352af5d35a9fce5b0af8c36ac326c9461ce3 100755 (executable)
                pinctrl-names = "default";
                pinctrl-0 = <&cap_int_status>;
                Semtech,button-flag = <0x0b>;
-               Semtech,reg-num = <1>;
-               Semtech,reg-init = < 0x4004 0x64 >;
+               Semtech,reg-num = <83>;
+               Semtech,reg-init = <
+               0x8020 0x1F0000
+               0x4004 0x64
+               0x4008 0x00
+               0x4054 0x400
+               0x42C0 0x8000000
+               0x42C4 0x3F
+               0x800C 0x00
+               0x8010 0x00
+               0x8014 0x00
+               0x8018 0x00
+               0x801C 0x58
+               0x8024 0x300014BE
+               0x8028 0x3FFE8267
+               0x802C 0x300014BE
+               0x8030 0x3FF7825B
+               0x8034 0x14BE
+               0x8038 0x3FBF8269
+               0x803C 0x1446
+               0x8040 0x3DFF825F
+               0x8044 0x300014BE
+               0x8048 0x2FFF82C4
+               0x804C 0x88E
+               0x8050 0x80001EE6
+               0x8054 0x10163F00
+               0x8058 0x60600031
+               0x805C 0x54AC5300
+               0x8060 0x00
+               0x8064 0x810000
+               0x8068 0x00
+               0x806C 0x21002100
+               0x8070 0x10000
+               0x8074 0x10162A00
+               0x8078 0x60600031
+               0x807C 0x54AC5300
+               0x8080 0x00
+               0x8084 0x460000
+               0x8088 0x00
+               0x808C 0x1E001E00
+               0x8090 0x10000
+               0x8094 0x1006C800
+               0x8098 0x60600931
+               0x809C 0x54AC4300
+               0x80A0 0x00
+               0x80A4 0x00
+               0x80A8 0x00
+               0x80AC 0x00
+               0x80B0 0x00
+               0x80B4 0x10163C00
+               0x80B8 0x60600031
+               0x80BC 0x54AC5300
+               0x80C0 0x00
+               0x80C4 0x5C0000
+               0x80C8 0x00
+               0x80CC 0x500050
+               0x80D0 0x20000
+               0x80D4 0x1006C800
+               0x80D8 0x60600931
+               0x80DC 0x54AC4300
+               0x80E0 0x00
+               0x80E4 0x00
+               0x80E8 0x00
+               0x80EC 0x00
+               0x80F0 0x00
+               0x80F4 0x10162800
+               0x80F8 0x20400031
+               0x80FC 0x54AC5300
+               0x8100 0x00
+               0x8104 0x00
+               0x8108 0x00
+               0x810C 0x00
+               0x8110 0x00
+               0x8124 0x4000004
+               0x8128 0x4000002
+               0x812C 0x00
+               0x8130 0x00
+               0x8134 0x00
+               0x8138 0x00
+               0x813C 0x00
+               0x8140 0x00
+               0x8144 0x00
+               0x8148 0x00
+               0x814C 0x00 
+               0x81A4 0x1C40008>;
                };
 
 
index 59a9fd4a4370048f78b3c6d38d69f49b651cc85f..fdeaff88b1b7eca7ad809b68d7456b8419cc5967 100755 (executable)
@@ -733,7 +733,7 @@ static const struct smtc_reg_data sx933x_i2c_reg_setup[] =
        {0x814C,0x00},
        {0x81A4,0x1C40001},
 };
-
+#define REG_PARAM_VER "21_19_2_enable_ref_adc_filter_3-0028_zero_added_ref_coef_and_thresh"
 #endif
 static struct _buttonInfo psmtcButtons[] =
 {
index 89975dafd7ae9618b0fd542d50f3f6da7c656fa4..209bcdb2b7446246e9b671cc302df7481f65f5d1 100755 (executable)
@@ -32,7 +32,7 @@
 #include "sx933x.h"    /* main struct, interrupt,init,pointers */
 
 
-#define SX933x_DEBUG 1
+#define SX933x_DEBUG 0
 #define LOG_TAG "[sar SX933x]: "
 
 #if SX933x_DEBUG
@@ -40,7 +40,7 @@
 #else
 #define LOG_INFO(fmt, args...)
 #endif
-#define LOG_DBG(fmt, args...)   pr_info(LOG_TAG fmt, ##args) 
+#define LOG_DBG(fmt, args...)   pr_info(LOG_TAG fmt, ##args)
 
 #define USE_DTS_REG
 
@@ -340,47 +340,58 @@ static ssize_t sx933x_register_read_store(struct device *dev,
        LOG_DBG("%s - Register(0x%2x) data(0x%4x) nirq_state(%d)\n",__func__, regist, val, nirq_state);
        return count;
 }
-static void read_dbg_raw(psx93XX_t this)
+static char* read_dbg_raw(psx93XX_t this, s32 *my_ant_raw, s32 *dlt_var_1, s32 *dlt_var_2)
 {
-       u32 uData;
-       s32 ref_raw, ant_raw;
-
-       sx933x_i2c_read_16bit(this, 0x81A4, &uData);
+       u32 uData, reg_val;
+       s32 ref_raw, ant_raw, ant_use;
 
-       //MANT_MLB
-       uData &= ~(0x7 << 3); //PH0
-       sx933x_i2c_write_16bit(this, 0x81A4, uData);
+       sx933x_i2c_read_16bit(this, 0x81A4, &reg_val);
        sx933x_i2c_read_16bit(this, 0x81B0, &uData);
        ant_raw = (s32)uData>>10;
+       *my_ant_raw = ant_raw;
 
-       //MANT_REF
-       uData &= ~(0x7 << 3);
-       uData |= 4 << 3; //PH4
-       sx933x_i2c_write_16bit(this, 0x81A4, uData);
-       sx933x_i2c_read_16bit(this, 0x81B0, &uData);
-       ref_raw = (s32)uData>>10;
+       sx933x_i2c_read_16bit(this, 0x81B4, &uData);
+       *dlt_var_1 = (s32)uData;
+       *dlt_var_2 = (s32)uData >> 3;
 
-       //MANT__HB
-       uData &= ~(0x7 << 3);
-       uData |= 1 << 3; //PH1
-       sx933x_i2c_write_16bit(this, 0x81A4, uData);
-       sx933x_i2c_read_16bit(this, 0x81B0, &uData);
-       ant_raw = (s32)uData>>10;
-
-       //DIV_ANT
-       uData &= ~(0x7 << 3);
-       uData |= 3 << 3; //PH3
-       sx933x_i2c_write_16bit(this, 0x81A4, uData);
-       sx933x_i2c_read_16bit(this, 0x81B0, &uData);
-       ant_raw = (s32)uData>>10;
+       //ph0
+       if((reg_val & (0x7 << 3)) == 0)
+       {
+               sx933x_i2c_read_16bit(this, SX933X_USEPH4_REG, &uData);
+               ref_raw = (s32)uData>>10;
+               sx933x_i2c_read_16bit(this, SX933X_USEPH0_REG, &uData);
+               ant_use = (s32)uData>>10;
 
-       //DIV_REF
-       uData &= ~(0x7 << 3);
-       uData |= 2 << 3; //PH2
-       sx933x_i2c_write_16bit(this, 0x81A4, uData);
-       sx933x_i2c_read_16bit(this, 0x81B0, &uData);
-       ref_raw = (s32)uData>>10;
+               LOG_DBG("reg_val=0x%X PH4_USE= %d PH0_USE= %d PH0_RAW= %d \n", reg_val, ref_raw, ant_use, ant_raw);
+               return "ph0_raw";
+       }
+       //ph1
+       else if((reg_val & (0x7 << 3)) == (1 << 3))
+       {               
+               sx933x_i2c_read_16bit(this, SX933X_USEPH4_REG, &uData);
+               ref_raw = (s32)uData>>10;
+               sx933x_i2c_read_16bit(this, SX933X_USEPH1_REG, &uData);
+               ant_use = (s32)uData>>10;
+
+               LOG_DBG("reg_val=0x%X PH4_USE= %d PH1_USE= %d PH1_RAW= %d \n", reg_val, ref_raw, ant_use, ant_raw);
+               return "ph1_raw";
+       }
+       //ph3
+       else if((reg_val & (0x7 << 3)) == (3 << 3))
+       {
+               sx933x_i2c_read_16bit(this, SX933X_USEPH2_REG, &uData);
+               ref_raw = (s32)uData>>10;
+               sx933x_i2c_read_16bit(this, SX933X_USEPH3_REG, &uData);
+               ant_use = (s32)uData>>10;
 
+               LOG_DBG("reg_val=0x%X PH2_USE= %d PH3_USE= %d PH3_RAW= %d \n", reg_val, ref_raw, ant_use, ant_raw);
+               return "ph3_raw";
+       }
+       else
+       {
+               LOG_DBG("invalid reg_val = 0x%X \n", reg_val);
+               return "inv_raw";
+       }
 }
 
 static void read_rawData(psx93XX_t this)
@@ -389,12 +400,25 @@ static void read_rawData(psx93XX_t this)
        s32 useful;
        s32 average;
        s32 diff;
+       s32 ph2_use, ph4_use, ant_raw, dlt_var_1, dlt_var_2;
        u32 uData;
        u16 offset;
-       s32 state = 0;
+       int state;
+       char *ant_raw_name;
 
        if(this)
        {
+               sx933x_i2c_read_16bit(this, SX933X_STAT0_REG, &uData);
+               LOG_DBG("SX933X_STAT0_REG[0x8000] = 0x%08X\n", uData);
+
+               sx933x_i2c_read_16bit(this, SX933X_USEPH2_REG, &uData);
+               ph2_use = (s32)uData >> 10;
+
+               sx933x_i2c_read_16bit(this, SX933X_USEPH4_REG, &uData);
+               ph4_use = (s32)uData >> 10;
+
+               ant_raw_name = read_dbg_raw(this, &ant_raw, &dlt_var_1, &dlt_var_2);
+
                for(csx =0; csx<5; csx++)
                {
                        index = csx*4;
@@ -407,10 +431,27 @@ static void read_rawData(psx93XX_t this)
                        sx933x_i2c_read_16bit(this, SX933X_OFFSETPH0_REG + index*2, &uData);
                        offset = (u16)(uData & 0x7FFF);
                        state = psmtcButtons[csx].state;
+                       if(csx == 0 || csx == 1)
+                       {
+                               LOG_DBG("[PH: %d] ref_use = %d Useful = %d DIFF = %d state = %d %s = %d Average = %d Offset = %d "
+                    "dlt_var_1 = %d dlt_var_2 = %d\n",
+                                       csx, ph4_use, useful, diff, state, ant_raw_name, ant_raw, average, offset,
+                                       dlt_var_1, dlt_var_2);
+                       }
+                       else if(csx == 3)
+                       {
+                               LOG_DBG("[PH: %d] ref_use = %d Useful = %d DIFF = %d state = %d %s = %d Average = %d Offset = %d "
+                    "dlt_var_1 = %d dlt_var_2 = %d\n",
+                                       csx, ph2_use, useful, diff, state, ant_raw_name, ant_raw, average, offset,
+                                       dlt_var_1, dlt_var_2);
+                       }
+                       else
+                       {
+                               LOG_DBG("[PH: %d] Useful = %d DIFF = %d state = %d Average = %d Offset = %d\n",
+                                       csx, useful, diff, state, average, offset);
+                       }
                }
        }
-       read_dbg_raw(this);
-
 }
 static ssize_t sx933x_all_reg_data_show(struct device *dev, struct device_attribute *attr, char *buf)
 {
@@ -419,12 +460,24 @@ static ssize_t sx933x_all_reg_data_show(struct device *dev, struct device_attrib
        char *p = buf;
        int i;
        psx93XX_t this = dev_get_drvdata(dev);
+
+       p += snprintf(p, PAGE_SIZE, "DRV_VER=%s\n", "1_decrease_init_time");
+
        for (i = 0; i < ARRAY_SIZE(sx933x_i2c_reg_setup); i++)
        {
                regist = (u16)(sx933x_i2c_reg_setup[i].reg);
                sx933x_i2c_read_16bit(this, regist, &val);
-               p += snprintf(p, PAGE_SIZE, "reg=(0x%04x)  value=0x%04x\n",
-                       regist,val);
+               
+               if (regist == SX933X_AFEPHPH0_REG ||
+                       regist == SX933X_AFEPHPH1_REG ||
+                       regist == SX933X_AFEPHPH2_REG ||
+                       regist == SX933X_AFEPHPH3_REG ||
+                       regist == SX933X_AFEPHPH4_REG)
+               {
+                       val &= ~0x7FFF;
+               }
+               
+               p += snprintf(p, PAGE_SIZE, "(reg,val) = (0x%X,0x%02X);\n", regist,val);
        }
        return (p-buf);
 }
@@ -543,13 +596,16 @@ static void sx933x_reg_init(psx93XX_t this)
        psx933x_t pDevice = 0;
        psx933x_platform_data_t pdata = 0;
        int i = 0;
+#ifndef USE_DTS_REG
        uint32_t tmpvalue;
+#endif
        /* configure device */
        if (this && (pDevice = this->pDevice) && (pdata = pDevice->hw))
        {
                /*******************************************************************************/
                // try to initialize from device tree!
                /*******************************************************************************/
+#ifndef USE_DTS_REG
                while ( i < ARRAY_SIZE(sx933x_i2c_reg_setup))
                {
                        /* Write all registers/values contained in i2c_reg */
@@ -566,7 +622,7 @@ static void sx933x_reg_init(psx93XX_t this)
                        sx933x_i2c_write_16bit(this, sx933x_i2c_reg_setup[i].reg, tmpvalue);
                        i++;
                }
-#ifdef USE_DTS_REG
+#else
                if (this->reg_in_dts == true)
                {
                        i = 0;
@@ -1318,7 +1374,7 @@ int sx93XX_IRQ_init(psx93XX_t this)
                INIT_DELAYED_WORK(&this->dworker, sx93XX_worker_func);
                /* initailize interrupt reporting */
                this->irq_disabled = 0;
-               err = request_irq(this->irq, sx93XX_irq, IRQF_TRIGGER_FALLING,
+               err = request_irq(this->irq, sx93XX_irq, IRQF_TRIGGER_FALLING | IRQF_ONESHOT,
                                this->pdev->driver->name, this);
                if (err)
                {