mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-13 00:00:00 -04:00
DLKM:control VDD off when sar sensor is off
It's used to save power. It's only used on Borneo NA Change-Id: I2aa60149f0a362dc29fc0eded5c509a9fd4ddc7c Signed-off-by: chenlj2 <chenlj2@motorola.com> Reviewed-on: https://gerrit.mot.com/1718145 SLTApproved: Slta Waiver SME-Granted: SME Approvals Granted Tested-by: Jira Key Reviewed-by: Jiacheng Ou <oujc1@motorola.com> Reviewed-by: Guoyue Liu <liugy11@motorola.com> Reviewed-by: Wang Wang <wangwang1@lenovo.com> Submit-Approved: Jira Key
This commit is contained in:
parent
cda4965add
commit
6bcd3fe49e
3 changed files with 63 additions and 6 deletions
|
|
@ -5,6 +5,10 @@ KERNEL_VERSION_NAME = $(shell basename $(KERNEL_DIR_PATH))
|
|||
EXTRA_CFLAGS += -Wall
|
||||
EXTRA_CFLAGS += -I$(TOP)/motorola/kernel/modules/include
|
||||
|
||||
ifneq (,$(filter borneo%,$(TARGET_PRODUCT)))
|
||||
EXTRA_CFLAGS += -DCONFIG_CAPSENSE_CONTROL_VDD
|
||||
endif
|
||||
|
||||
ifneq (,$(KERNEL_DIR_PATH))
|
||||
EXTRA_CFLAGS += -I$(TOP)/kernel/$(KERNEL_VERSION_NAME)/drivers/base
|
||||
else
|
||||
|
|
|
|||
|
|
@ -821,6 +821,35 @@ static ssize_t enable_show(struct class *class,
|
|||
return snprintf(buf, 8, "%d\n", mEnabled);
|
||||
}
|
||||
|
||||
#ifdef CONFIG_CAPSENSE_CONTROL_VDD
|
||||
static void abov_power(bool on)
|
||||
{
|
||||
pabovXX_t this = abov_sar_ptr;
|
||||
int ret;
|
||||
|
||||
if (on) {
|
||||
ret = regulator_enable(this->board->cap_vdd);
|
||||
if (ret) {
|
||||
regulator_put(this->board->cap_vdd);
|
||||
LOG_ERR("%s: Error %d enable regulator\n",
|
||||
__func__, ret);
|
||||
}
|
||||
this->board->cap_vdd_en = true;
|
||||
LOG_INFO("cap_vdd regulator is %s\n",
|
||||
regulator_is_enabled(this->board->cap_vdd) ?
|
||||
"on" : "off");
|
||||
SLEEP(100);
|
||||
} else {
|
||||
regulator_disable(this->board->cap_vdd);
|
||||
//regulator_put(this->board->cap_vdd);
|
||||
this->board->cap_vdd_en = false;
|
||||
LOG_INFO("cap_vdd regulator is %s\n",
|
||||
regulator_is_enabled(this->board->cap_vdd) ?
|
||||
"on" : "off");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
static ssize_t enable_store(struct class *class,
|
||||
struct class_attribute *attr,
|
||||
const char *buf, size_t count)
|
||||
|
|
@ -847,6 +876,10 @@ static ssize_t enable_store(struct class *class,
|
|||
|
||||
if (!strncmp(buf, "1", 1)) {
|
||||
LOG_INFO("enable cap sensor\n");
|
||||
#ifdef CONFIG_CAPSENSE_CONTROL_VDD
|
||||
if (!this->board->cap_vdd_en)
|
||||
abov_power(true);
|
||||
#endif
|
||||
initialize(this);
|
||||
|
||||
input_report_abs(input_ch0, ABS_DISTANCE, 0);
|
||||
|
|
@ -881,6 +914,10 @@ static ssize_t enable_store(struct class *class,
|
|||
input_report_abs(input_ch3, ABS_DISTANCE, -1);
|
||||
input_sync(input_ch3);
|
||||
}
|
||||
#ifdef CONFIG_CAPSENSE_CONTROL_VDD
|
||||
if (this->board->cap_vdd_en)
|
||||
abov_power(false);
|
||||
#endif
|
||||
mEnabled = 0;
|
||||
} else {
|
||||
LOG_ERR("unknown enable symbol\n");
|
||||
|
|
@ -912,6 +949,10 @@ static int capsensor_set_enable(struct sensors_classdev *sensors_cdev, unsigned
|
|||
if (enable == 1) {
|
||||
LOG_INFO("enable cap sensor: %s\n",sensors_cdev->name);
|
||||
if(mEnabled == 0){
|
||||
#ifdef CONFIG_CAPSENSE_CONTROL_VDD
|
||||
if (!this->board->cap_vdd_en)
|
||||
abov_power(true);
|
||||
#endif
|
||||
initialize(this);
|
||||
mEnabled = 1;
|
||||
}
|
||||
|
|
@ -1007,6 +1048,10 @@ static int capsensor_set_enable(struct sensors_classdev *sensors_cdev, unsigned
|
|||
mEnabled = 0;
|
||||
write_register(this, ABOV_CTRL_MODE_REG, 0x02);
|
||||
LOG_INFO("all cap sensor disable,change to STOP mode.\n");
|
||||
#ifdef CONFIG_CAPSENSE_CONTROL_VDD
|
||||
if(this->board->cap_vdd_en)
|
||||
abov_power(false);
|
||||
#endif
|
||||
}
|
||||
} else {
|
||||
LOG_ERR("unknown enable symbol\n");
|
||||
|
|
@ -1656,8 +1701,12 @@ static void capsense_update_work(struct work_struct *work)
|
|||
|
||||
if(mEnabled){
|
||||
initialize(this);
|
||||
#ifdef CONFIG_CAPSENSE_CONTROL_VDD
|
||||
} else if (this->board->cap_vdd_en) {
|
||||
abov_power(false);
|
||||
#endif
|
||||
}
|
||||
LOG_DBG("%s: update firmware end\n", __func__);
|
||||
LOG_INFO("%s: update firmware end\n", __func__);
|
||||
}
|
||||
|
||||
static void capsense_fore_update_work(struct work_struct *work)
|
||||
|
|
@ -1681,8 +1730,12 @@ static void capsense_fore_update_work(struct work_struct *work)
|
|||
|
||||
if(mEnabled){
|
||||
initialize(this);
|
||||
#ifdef CONFIG_CAPSENSE_CONTROL_VDD
|
||||
} else if (this->board->cap_vdd_en) {
|
||||
abov_power(false);
|
||||
#endif
|
||||
}
|
||||
LOG_DBG("%s: force update firmware end\n", __func__);
|
||||
LOG_INFO("%s: force update firmware end\n", __func__);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -232,10 +232,10 @@ static struct sensors_classdev sensors_capsensor_ch3_cdev = {
|
|||
|
||||
|
||||
typedef enum{
|
||||
CAPSENSOR_ENABLE_FLAG_CH0,
|
||||
CAPSENSOR_ENABLE_FLAG_CH1,
|
||||
CAPSENSOR_ENABLE_FLAG_CH2,
|
||||
CAPSENSOR_ENABLE_FLAG_CH3,
|
||||
CAPSENSOR_ENABLE_FLAG_CH0=1,
|
||||
CAPSENSOR_ENABLE_FLAG_CH1=2,
|
||||
CAPSENSOR_ENABLE_FLAG_CH2=4,
|
||||
CAPSENSOR_ENABLE_FLAG_CH3=8,
|
||||
CAPSENSOR_ENABLE_FLAG_MAX
|
||||
}capsensor_enable_flag_t;
|
||||
/***************************************
|
||||
|
|
|
|||
Loading…
Reference in a new issue