summaryrefslogtreecommitdiff
path: root/driver/als_tcs3400.c
diff options
context:
space:
mode:
authorNick Vaccaro <nvaccaro@google.com>2019-05-07 12:48:56 -0700
committerchrome-bot <chrome-bot@chromium.org>2019-05-09 16:05:59 -0700
commit2d38e7cd712834d763ff59704cd04af2a95b8367 (patch)
tree25b44b030408b514217b9c91e08fd1fe9696ae88 /driver/als_tcs3400.c
parentd600316362ef86d893d0f65db73e962184d8c3ce (diff)
downloadchrome-ec-2d38e7cd712834d763ff59704cd04af2a95b8367.tar.gz
tcs3400: rename tcs3400_drv_data_t to als_drv_data_t
- rename tsc3400_drv_data_t to als_drv_data_t - change tcs3400 driver to use common als_drv_data_t - change flapjack config to use common als_drv_data_t - rename TSC3400_SCALE() macro to ALS_CHANNEL_SCALE() - create and use new I2C_PORT_ALS definition - fix a couple nits BUG=b:124512628 BRANCH=master TEST=build and flash to flapjack, verify ALS and RGB still work. Change-Id: I9a45d255ff77794ef34026406c9b702a04e09c11 Signed-off-by: Nick Vaccaro <nvaccaro@google.com> Reviewed-on: https://chromium-review.googlesource.com/1601052 Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com> Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
Diffstat (limited to 'driver/als_tcs3400.c')
-rw-r--r--driver/als_tcs3400.c38
1 files changed, 19 insertions, 19 deletions
diff --git a/driver/als_tcs3400.c b/driver/als_tcs3400.c
index e821b6bb9c..213e5424fd 100644
--- a/driver/als_tcs3400.c
+++ b/driver/als_tcs3400.c
@@ -70,7 +70,7 @@ static int tcs3400_post_events(struct motion_sensor_t *s, uint32_t last_ts)
* routine will only get called from ALS sensor driver.
*/
struct motion_sensor_t *rgb_s = s + 1;
- struct tcs3400_drv_data_t *drv_data = TCS3400_DRV_DATA(s);
+ struct als_drv_data_t *drv_data = TCS3400_DRV_DATA(s);
struct tcs3400_rgb_drv_data_t *rgb_drv_data =
TCS3400_RGB_DRV_DATA(rgb_s);
struct ec_response_motion_sensor_data vector;
@@ -153,7 +153,7 @@ skip_clear_vector_load:
rgb_data[i] = ((light_data[index] << 8) | light_data[index-1]);
rgb_data[i] += rgb_drv_data->rgb_cal[i].offset;
- rgb_data[i] *= rgb_drv_data->rgb_cal[i].scale / BIT(15);
+ rgb_data[i] *= rgb_drv_data->rgb_cal[i].scale >> 15;
rgb_data[i] = rgb_data[i] * rgb_drv_data->device_scale +
rgb_data[i] * rgb_drv_data->device_uscale / 10000;
@@ -194,7 +194,6 @@ skip_vector_load:
vector.sensor_num = rgb_s - motion_sensors;
motion_sense_fifo_add_data(&vector, rgb_s, 3, last_ts);
}
-
return EC_SUCCESS;
}
@@ -235,7 +234,6 @@ static int tcs3400_irq_handler(struct motion_sensor_t *s, uint32_t *event)
if ((status & TCS_I2C_STATUS_RGBC_VALID) ||
((status & TCS_I2C_STATUS_ALS_IRQ) &&
(status & TCS_I2C_STATUS_ALS_VALID))) {
-
ret = tcs3400_post_events(s, last_interrupt_timestamp);
if (ret)
return ret;
@@ -401,26 +399,28 @@ static int tcs3400_init(const struct motion_sensor_t *s)
{
/*
* These are default power-on register values with two exceptions:
- * Set ATIME = 0x4 (700.88ms)
+ * Set ATIME = 0 (712 ms)
* Set AGAIN = 16 (0x10) (AGAIN is in CONTROL register)
*/
const struct reg_data {
uint8_t reg;
uint8_t data;
- } defaults[] = { { TCS_I2C_ENABLE, 0 },
- { TCS_I2C_ATIME, 0x4 },
- { TCS_I2C_WTIME, 0xFF },
- { TCS_I2C_AILTL, 0 },
- { TCS_I2C_AILTH, 0 },
- { TCS_I2C_AIHTL, 0 },
- { TCS_I2C_AIHTH, 0 },
- { TCS_I2C_PERS, 0 },
- { TCS_I2C_CONFIG, 0x40 },
- { TCS_I2C_CONTROL, 0x10 },
- { TCS_I2C_AUX, 0 },
- { TCS_I2C_IR, 0 },
- { TCS_I2C_CICLEAR, 0 },
- { TCS_I2C_AICLEAR, 0 } };
+ } defaults[] = {
+ { TCS_I2C_ENABLE, 0 },
+ { TCS_I2C_ATIME, TCS_DEFAULT_ATIME },
+ { TCS_I2C_WTIME, 0xFF },
+ { TCS_I2C_AILTL, 0 },
+ { TCS_I2C_AILTH, 0 },
+ { TCS_I2C_AIHTL, 0 },
+ { TCS_I2C_AIHTH, 0 },
+ { TCS_I2C_PERS, 0 },
+ { TCS_I2C_CONFIG, 0x40 },
+ { TCS_I2C_CONTROL, (TCS_DEFAULT_AGAIN & TCS_I2C_CONTROL_MASK)},
+ { TCS_I2C_AUX, 0 },
+ { TCS_I2C_IR, 0 },
+ { TCS_I2C_CICLEAR, 0 },
+ { TCS_I2C_AICLEAR, 0 }
+ };
int data = 0;
int ret;