(CR):[kane]:kernel:add Capsensor calibrate value node
authoryanfei <yanfei5@huaqin.com>
Mon, 22 Oct 2018 03:14:18 +0000 (11:14 +0800)
committerxiest1 <xiest1@lenovo.com>
Tue, 5 Nov 2019 09:29:49 +0000 (17:29 +0800)
Add Capsensor calibrate value node

Change-Id: I847e6dcf19d3856726fb2fda0111c0b7d3c646e4
Signed-off-by: yanfei <yanfei5@huaqin.com>
drivers/input/misc/sx933x.h
drivers/input/misc/sx933x_sar.c

index f2877e48da34c96ba8beb05ead9ce65c1a5dad76..750e818c6ea2ccac4cbe277195da3a9e5d61c6de 100755 (executable)
 #define   SX933X_STAT0_BODYSTAT_PH0_FLAG      0x00000100
 
 /*      Chip ID        */
-#define SX933X_WHOAMI_VALUE                   0x00003113
+#define SX933X_WHOAMI_VALUE                   0x00003114
 /*command*/
 #define SX933X_PHASE_CONTROL                  0x0000000F
 #define SX933X_COMPENSATION_CONTROL           0x0000000E
 #define SX933X_EXIT_CONTROL                   0x0000000C
 
 
+#define SX933X_HARDWARE_CHECK_SUCCESS         1
+#define SX933X_HARDWARE_CHECK_FAIL            0
+
 
 
 /**************************************
index a46838a4bc9605d3cfcbdfd8f3bd26badbe41adc..7a3b112915e0f30cfa3759b3dd0a0869c6c86fc3 100755 (executable)
@@ -396,12 +396,68 @@ static ssize_t sx933x_raw_data_show(struct device *dev, struct device_attribute
        }
        return (p-buf);
 }
+static ssize_t sx933x_diff_data_show(struct device *dev, struct device_attribute *attr, char *buf)
+{
+       char *p = buf;
+       int csx;
+       s32 diff;
+       u32 uData;
+       psx93XX_t this = dev_get_drvdata(dev);
+       if(this) {
+               for(csx =0; csx<5; csx++) {
+                       sx933x_i2c_read_16bit(this, SX933X_DIFFPH0_REG + csx*4, &uData);
+                       diff = (s32)uData>>10;
+                       p += snprintf(p, PAGE_SIZE, "[PH: %d] DIFF = 0x%04x\n",
+                                       csx,diff);
+               }
+       }
+       return (p-buf);
+}
+static ssize_t sx933x_hardware_id_show(struct device *dev, struct device_attribute *attr, char *buf)
+{
+       int ret;
+       u32 idCode;
+       u8 loop = 0;
+       int result = 0;
+
+       psx93XX_t this = dev_get_drvdata(dev);
+       this->failStatusCode = 0;
+       //Check th IRQ Status
+       while(this->get_nirq_low && this->get_nirq_low())
+       {
+               read_regStat(this);
+               msleep(100);
+               if(++loop >10)
+               {
+                       result = SX933x_NIRQ_ERROR;
+                       break;
+               }
+       }
 
+       //Check I2C Connection
+       ret = sx933x_i2c_read_16bit(this, SX933X_INFO_REG, &idCode);
+       if(ret < 0)
+       {
+               result = SX933x_I2C_ERROR;
+       }
+
+       if(idCode!= SX933X_WHOAMI_VALUE)
+       {
+               result = SX933x_ID_ERROR;
+       }
+       if(result == 0)
+               result = SX933X_HARDWARE_CHECK_SUCCESS;
+       else
+               result = SX933X_HARDWARE_CHECK_FAIL;
+       return sprintf(buf, "%d\n", result);
+}
 static DEVICE_ATTR(manual_calibrate, 0664, manual_offset_calibration_show,manual_offset_calibration_store);
 static DEVICE_ATTR(manual_calibrate_value, 0664, manual_offset_calibration_value_show, NULL);
 static DEVICE_ATTR(register_write,  0664, NULL,sx933x_register_write_store);
 static DEVICE_ATTR(register_read,0664, NULL,sx933x_register_read_store);
 static DEVICE_ATTR(raw_data,0664,sx933x_raw_data_show,NULL);
+static DEVICE_ATTR(diff_data,0664,sx933x_diff_data_show,NULL);
+static DEVICE_ATTR(hardware_id,0664,sx933x_hardware_id_show,NULL);
 
 static struct attribute *sx933x_attributes[] =
 {
@@ -410,6 +466,8 @@ static struct attribute *sx933x_attributes[] =
        &dev_attr_register_write.attr,
        &dev_attr_register_read.attr,
        &dev_attr_raw_data.attr,
+       &dev_attr_diff_data.attr,
+       &dev_attr_hardware_id.attr,
        NULL,
 };
 static struct attribute_group sx933x_attr_group =