summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLinux Build Service Account <lnxbuild@localhost>2017-04-05 04:05:36 -0700
committerGerrit - the friendly Code Review server <code-review@localhost>2017-04-05 04:05:36 -0700
commit078448a790504aaa64cd58834c2ad4fbc293e57d (patch)
tree6a89b71aacff3669a3f2ce161a213abf8799ba3e
parente81f37a9e52fe0b4a857c6988a6e6073579b08f9 (diff)
parent16b008e2155d6c5c0dfca8ff98a903d9d72690f5 (diff)
Merge "Input: stm: optimize the laser sensor driver"
-rw-r--r--drivers/input/misc/vl53L0/stmvl53l0.h1
-rw-r--r--drivers/input/misc/vl53L0/stmvl53l0_module-cci.c14
-rw-r--r--drivers/input/misc/vl53L0/stmvl53l0_module.c12
3 files changed, 21 insertions, 6 deletions
diff --git a/drivers/input/misc/vl53L0/stmvl53l0.h b/drivers/input/misc/vl53L0/stmvl53l0.h
index ae517ebe461a..b15d78cc6825 100644
--- a/drivers/input/misc/vl53L0/stmvl53l0.h
+++ b/drivers/input/misc/vl53L0/stmvl53l0.h
@@ -131,6 +131,7 @@ struct stmvl53l0_data {
struct miscdevice miscdev;
int irq;
+ int irq_gpio;
unsigned int reset;
/* control flag from HAL */
diff --git a/drivers/input/misc/vl53L0/stmvl53l0_module-cci.c b/drivers/input/misc/vl53L0/stmvl53l0_module-cci.c
index e08edbcc73f9..79fba00ea086 100644
--- a/drivers/input/misc/vl53L0/stmvl53l0_module-cci.c
+++ b/drivers/input/misc/vl53L0/stmvl53l0_module-cci.c
@@ -248,6 +248,7 @@ static int stmvl53l0_cci_init(struct cci_data *data)
cci_client->retries = 3;
cci_client->id_map = 0;
cci_client->cci_i2c_master = data->cci_master;
+ cci_client->i2c_freq_mode = I2C_FAST_MODE;
rc = data->client->i2c_func_tbl->i2c_util(data->client, MSM_CCI_INIT);
if (rc < 0) {
vl53l0_errmsg("%d: CCI Init failed\n", __LINE__);
@@ -295,8 +296,20 @@ static int32_t stmvl53l0_platform_probe(struct platform_device *pdev)
rc = stmvl53l0_get_dt_data(&pdev->dev, cci_object);
if (rc < 0) {
vl53l0_errmsg("%d, failed rc %d\n", __LINE__, rc);
+ kfree(vl53l0_data->client_object);
+ kfree(vl53l0_data);
return rc;
}
+ vl53l0_data->irq_gpio = of_get_named_gpio_flags(pdev->dev.of_node,
+ "stm,irq-gpio", 0, NULL);
+
+ if (!gpio_is_valid(vl53l0_data->irq_gpio)) {
+ vl53l0_errmsg("%d failed get irq gpio", __LINE__);
+ kfree(vl53l0_data->client_object);
+ kfree(vl53l0_data);
+ return -EINVAL;
+ }
+
cci_object->subdev_id = pdev->id;
/* Set device type as platform device */
@@ -418,6 +431,7 @@ int stmvl53l0_power_up_cci(void *cci_object, unsigned int *preset_flag)
}
}
data->power_up = 1;
+ usleep_range(3000, 3500);
*preset_flag = 1;
vl53l0_dbgmsg("End\n");
diff --git a/drivers/input/misc/vl53L0/stmvl53l0_module.c b/drivers/input/misc/vl53L0/stmvl53l0_module.c
index f242e5f497d0..6881aba9fc64 100644
--- a/drivers/input/misc/vl53L0/stmvl53l0_module.c
+++ b/drivers/input/misc/vl53L0/stmvl53l0_module.c
@@ -38,8 +38,8 @@
#include "vl53l0_api.h"
#include "vl53l010_api.h"
-/*#define USE_INT */
-#define IRQ_NUM 59
+#define USE_INT
+
/* #define DEBUG_TIME_LOG */
#ifdef DEBUG_TIME_LOG
struct timeval start_tv, stop_tv;
@@ -2668,12 +2668,12 @@ int stmvl53l0_setup(struct stmvl53l0_data *data)
#ifdef USE_INT
/* init interrupt */
- gpio_request(IRQ_NUM, "vl53l0_gpio_int");
- gpio_direction_input(IRQ_NUM);
- irq = gpio_to_irq(IRQ_NUM);
+ gpio_request(data->irq_gpio, "vl53l0_gpio_int");
+ gpio_direction_input(data->irq_gpio);
+ irq = gpio_to_irq(data->irq_gpio);
if (irq < 0) {
vl53l0_errmsg("filed to map GPIO: %d to interrupt:%d\n",
- IRQ_NUM, irq);
+ data->irq_gpio, irq);
} else {
vl53l0_dbgmsg("register_irq:%d\n", irq);
/* IRQF_TRIGGER_FALLING- poliarity:0 IRQF_TRIGGER_RISNG -