summaryrefslogtreecommitdiff
path: root/driver/als_opt3001.c
diff options
context:
space:
mode:
authorVijay Hiremath <vijay.p.hiremath@intel.com>2015-09-23 12:30:14 -0700
committerchrome-bot <chrome-bot@chromium.org>2015-10-02 12:55:51 -0700
commit229094b2455e093c95d07251a0021f3b637e813c (patch)
tree9f9000c571d4c4dca79737902d14fe4a6a84643f /driver/als_opt3001.c
parent2aebfda07f3fe4d3ee058022f088283b35f4f976 (diff)
downloadchrome-ec-229094b2455e093c95d07251a0021f3b637e813c.tar.gz
ALS: Disable the ALS task if all the ALS inits fail
BUG=none TEST=Manually tested on Kunimitsu & Strago. Removed the ALS sensor from DUT, using "taskinfo" console command observed that the ALS task is not running. BRANCH=none Change-Id: I96cb720bd8d70033d433cdc2cd9cea9b56a3b389 Signed-off-by: Vijay Hiremath <vijay.p.hiremath@intel.com> Reviewed-on: https://chromium-review.googlesource.com/301753 Commit-Ready: Vijay P Hiremath <vijay.p.hiremath@intel.com> Tested-by: Vijay P Hiremath <vijay.p.hiremath@intel.com> Reviewed-by: Shawn N <shawnn@chromium.org>
Diffstat (limited to 'driver/als_opt3001.c')
-rw-r--r--driver/als_opt3001.c29
1 files changed, 7 insertions, 22 deletions
diff --git a/driver/als_opt3001.c b/driver/als_opt3001.c
index 712b70a00d..4c5fa5d9f9 100644
--- a/driver/als_opt3001.c
+++ b/driver/als_opt3001.c
@@ -6,13 +6,7 @@
*/
#include "driver/als_opt3001.h"
-#include "common.h"
-#include "console.h"
-#include "hooks.h"
#include "i2c.h"
-#include "timer.h"
-
-#define CPRINTF(format, args...) cprintf(CC_I2C, format, ## args)
/**
* Read register from OPT3001 light sensor.
@@ -45,22 +39,18 @@ static int opt3001_i2c_write(const int reg, int data)
/**
* Initialise OPT3001 light sensor.
*/
-static void opt3001_init(void)
+int opt3001_init(void)
{
int data;
int ret;
ret = opt3001_i2c_read(OPT3001_REG_MAN_ID, &data);
- if (ret || data != OPT3001_MANUFACTURER_ID) {
- CPRINTF("ALS init failed: ret=%d, data=0x%x\n", ret, data);
- return;
- }
+ if (ret || data != OPT3001_MANUFACTURER_ID)
+ return ret;
ret = opt3001_i2c_read(OPT3001_REG_DEV_ID, &data);
- if (ret || data != OPT3001_DEVICE_ID) {
- CPRINTF("ALS init failed: ret=%d, data=0x%x\n", ret, data);
- return;
- }
+ if (ret || data != OPT3001_DEVICE_ID)
+ return ret;
/*
* [15:12]: 0101b Automatic full scale (1310.40lux, 0.32lux/lsb)
@@ -68,11 +58,8 @@ static void opt3001_init(void)
* [10:9] : 10b Continuous Mode of conversion operation
* [4] : 1b Latched window-style comparison operation
*/
- ret = opt3001_i2c_write(OPT3001_REG_CONFIGURE, 0x5C10);
- if (ret)
- CPRINTF("ALS configure failed: ret=%d\n", ret);
+ return opt3001_i2c_write(OPT3001_REG_CONFIGURE, 0x5C10);
}
-DECLARE_HOOK(HOOK_CHIPSET_RESUME, opt3001_init, HOOK_PRIO_DEFAULT + 1);
/**
* Read OPT3001 light sensor data.
@@ -83,10 +70,8 @@ int opt3001_read_lux(int *lux, int af)
int data;
ret = opt3001_i2c_read(OPT3001_REG_RESULT, &data);
- if (ret) {
- CPRINTF("ALS read failed: ret=%d\n", ret);
+ if (ret)
return ret;
- }
/*
* The default power-on values will give 12 bits of precision: