From 389ec5c887f1892ee280043bafe987f0821c6710 Mon Sep 17 00:00:00 2001 From: yanfei Date: Mon, 22 Oct 2018 11:14:18 +0800 Subject: [PATCH] EKKANE-32:[kane]:kernel:add Capsensor calibrate value node Add Capsensor calibrate value node Change-Id: I847e6dcf19d3856726fb2fda0111c0b7d3c646e4 Signed-off-by: yanfei --- drivers/input/misc/sx933x.h | 5 ++- drivers/input/misc/sx933x_sar.c | 58 +++++++++++++++++++++++++++++++++ 2 files changed, 62 insertions(+), 1 deletion(-) diff --git a/drivers/input/misc/sx933x.h b/drivers/input/misc/sx933x.h index f2877e48da34..750e818c6ea2 100755 --- a/drivers/input/misc/sx933x.h +++ b/drivers/input/misc/sx933x.h @@ -247,7 +247,7 @@ #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 @@ -255,6 +255,9 @@ #define SX933X_EXIT_CONTROL 0x0000000C +#define SX933X_HARDWARE_CHECK_SUCCESS 1 +#define SX933X_HARDWARE_CHECK_FAIL 0 + /************************************** diff --git a/drivers/input/misc/sx933x_sar.c b/drivers/input/misc/sx933x_sar.c index a46838a4bc96..7a3b112915e0 100755 --- a/drivers/input/misc/sx933x_sar.c +++ b/drivers/input/misc/sx933x_sar.c @@ -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 = -- 2.20.1