summaryrefslogtreecommitdiff
path: root/driver
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
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')
-rw-r--r--driver/als_isl29035.c8
-rw-r--r--driver/als_isl29035.h1
-rw-r--r--driver/als_opt3001.c29
-rw-r--r--driver/als_opt3001.h1
4 files changed, 11 insertions, 28 deletions
diff --git a/driver/als_isl29035.c b/driver/als_isl29035.c
index f908e443bd..357cc99089 100644
--- a/driver/als_isl29035.c
+++ b/driver/als_isl29035.c
@@ -6,10 +6,7 @@
*/
#include "driver/als_isl29035.h"
-#include "common.h"
-#include "hooks.h"
#include "i2c.h"
-#include "timer.h"
/* I2C interface */
#define ILS29035_I2C_ADDR 0x88
@@ -23,17 +20,16 @@
#define ILS29035_REG_INT_HT_MSB 7
#define ILS29035_REG_ID 15
-static void isl29035_init(void)
+int isl29035_init(void)
{
/*
* Tell it to read continually. This uses 70uA, as opposed to nearly
* zero, but it makes the hook/update code cleaner (we don't want to
* wait 90ms to read on demand while processing hook callbacks).
*/
- (void)i2c_write8(I2C_PORT_ALS, ILS29035_I2C_ADDR,
+ return i2c_write8(I2C_PORT_ALS, ILS29035_I2C_ADDR,
ILS29035_REG_COMMAND_I, 0xa0);
}
-DECLARE_HOOK(HOOK_CHIPSET_RESUME, isl29035_init, HOOK_PRIO_DEFAULT);
int isl29035_read_lux(int *lux, int af)
{
diff --git a/driver/als_isl29035.h b/driver/als_isl29035.h
index 0546ceb2d2..0a2f18f72c 100644
--- a/driver/als_isl29035.h
+++ b/driver/als_isl29035.h
@@ -8,6 +8,7 @@
#ifndef __CROS_EC_ALS_ISL29035_H
#define __CROS_EC_ALS_ISL29035_H
+int isl29035_init(void);
int isl29035_read_lux(int *lux, int af);
#endif /* __CROS_EC_ALS_ISL29035_H */
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:
diff --git a/driver/als_opt3001.h b/driver/als_opt3001.h
index b9c7714c0b..3e21ba7db8 100644
--- a/driver/als_opt3001.h
+++ b/driver/als_opt3001.h
@@ -26,6 +26,7 @@
#define OPT3001_MANUFACTURER_ID 0x5449
#define OPT3001_DEVICE_ID 0x3001
+int opt3001_init(void);
int opt3001_read_lux(int *lux, int af);
#endif /* __CROS_EC_ALS_OPT3001_H */