summaryrefslogtreecommitdiff
path: root/driver/als_tcs3400.c
Commit message (Collapse)AuthorAgeFilesLines
* driver: Sort header filesJeremy Bettis2022-11-291-1/+1
| | | | | | | | | | | | | | | | | | | | | Sort all includes in driver with the clang-format rules used by the zephyr project. BRANCH=None BUG=b:247100970 TEST=zmake build -a TEST=./twister --clobber -v -i TEST=make -j72 buildall_only runtests TEST=zmake compare-builds -a Signed-off-by: Jeremy Bettis <jbettis@google.com> Change-Id: I675e0db416b6b7cbcfce031c97fd24ad97b66f4f Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4052767 Reviewed-by: Yuval Peress <peress@google.com> Commit-Queue: Jeremy Bettis <jbettis@chromium.org> Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com> Tested-by: Jeremy Bettis <jbettis@chromium.org> Reviewed-by: Tom Hughes <tomhughes@chromium.org>
* Update license boilerplate text in source code filesMike Frysinger2022-09-121-1/+1
| | | | | | | | | | | | | | | Normally we don't do this, but enough changes have accumulated that we're doing a tree-wide one-off update of the name & style. BRANCH=none BUG=chromium:1098010 TEST=`repo upload` works Change-Id: Icd3a1723c20595356af83d190b2c6a9078b3013b Signed-off-by: Mike Frysinger <vapier@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3891203 Reviewed-by: Jeremy Bettis <jbettis@chromium.org> Reviewed-by: Jack Rosenthal <jrosenth@chromium.org>
* driver/als_tcs3400.c: Format with clang-formatJack Rosenthal2022-06-291-121/+113
| | | | | | | | | | | BUG=b:236386294 BRANCH=none TEST=none Change-Id: I574d6bbc4d010b9891c5ca38c81c60f13b2ac870 Signed-off-by: Jack Rosenthal <jrosenth@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3729905 Reviewed-by: Jeremy Bettis <jbettis@chromium.org>
* tcs3400: Use CONFIG_<driver>_INT_ENABLEGwendal Grignou2022-05-231-34/+26
| | | | | | | | | | | | | | | Use CONFIG_<driver>_INT_ENABLE to not include interrupt() and irq_handler() when hardware interrupt are not used. Disable call to motion_sense_fifo() with IS_ENABLED(CONFIG_ACCEL_FIFO). BUG=b:230401133 BRANCH=asurada,dedede,brya TEST=Build all. Check Zephyr with herobrine. Check on bugzzy. Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Change-Id: Ifc158d739f2b8f1664323af635dad5017f0761e1 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3609127 Reviewed-by: Yuval Peress <peress@google.com>
* zephyr: suppress warnings about pointers to unaligned dataMichał Barnaś2022-02-171-1/+3
| | | | | | | | | | | | | | | | | Zephyr has enabled warnings about pointers to members of packed structs. This resulted in failing compilation process. This commit supresses some warnings by using void* intermediate pointers and by using temporary variables if possible. BUG=b:210501420 BRANCH=main TEST=zmake testall && make buildall Change-Id: Ia03322e80ae2b4ba42731b066066cc466bd92baf Signed-off-by: Michał Barnaś <mb@semihalf.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3405041 Reviewed-by: Ting Shen <phoenixshen@chromium.org> Reviewed-by: Sam Hurst <shurst@google.com>
* driver/tcs3400: Set timestamp when emulating interruptGwendal Grignou2022-02-151-18/+13
| | | | | | | | | | | | | | | | | | | | | | | Use the same interrupt handler for wire or emulated interrupt, so we are sure to timestamp the samples. BUG=b:218890983,b:129419982 TEST=make -j buildall Check on kukui/krane that tast test hardware.SensorIioserviceHard passes. It would fail previously with error like: "error during validation: too much delta between samples for lid cros-ec-gyro at index 174(1m52.310435376s): got 14.894431ms; want <= 7.5ms" BRANCH=kukui,asurada Fixes: commit ae22b703601 ("driver: add an option to emulate irq event in TCS3400") Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Change-Id: I9f4deaa214abe6e8ac7a2aa6b6071a02565f8825 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3454215 Reviewed-by: Ting Shen <phoenixshen@chromium.org>
* ec: Fix returning uninitialized varsJeremy Bettis2021-08-241-3/+3
| | | | | | | | | | | | | | | | | | | | And just to make it clearer, don't return ret at the bottom of a if all other cases already do if (ret) return ret; As it turns out, building with coverage doesn't initialize vars to 0. BUG=None TEST=zmake coverage. BRANCH=none Change-Id: Iae5368673517724fd23cb01425c027db9a50644b Signed-off-by: Jeremy Bettis <jbettis@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3115428 Tested-by: Jeremy Bettis <jbettis@chromium.org> Auto-Submit: Jeremy Bettis <jbettis@chromium.org> Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-by: Keith Short <keithshort@chromium.org> Commit-Queue: Jeremy Bettis <jbettis@chromium.org>
* zephyr: DT: support TCS3400Hyungwoo Yang2021-03-241-0/+20
| | | | | | | | | | | | | | | | | | This change is to support TCS3400 via DT. The change includes, using DT, - creating TCS3400 driver specific data - creating motion sensor entry for TCS3400 - creating the TCS3400 irq event to motion sense task BUG=b:173507858 BRANCH=none TEST=make buildall -j8 build volteer on zephyr Signed-off-by: Hyungwoo Yang <hyungwoo.yang@intel.corp-partner.google.com> Change-Id: I09cb7d69baa95c8450c7f5cc0149038aa23f3bc9 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2778822 Reviewed-by: Simon Glass <sjg@chromium.org>
* driver/tcs3400: code cleanups for custom equationZick Wei2021-03-081-6/+11
| | | | | | | | | | | | | | | | | | This patch make tcs3400_translate_to_xyz() to overridable, let board could custom their own equation. BUG=b:176671564 BRANCH=None TEST=make BOARD=dooly Signed-off-by: Zick Wei <zick.wei@quanta.corp-partner.google.com> Change-Id: Ia475e03b995223575f9e3ff106bc12a406062c9b Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2738582 Tested-by: Zick Wei <zick.wei@quanta.corp-partner.google.com> Tested-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-by: Gwendal Grignou <gwendal@chromium.org> Commit-Queue: Gwendal Grignou <gwendal@chromium.org>
* driver: tcs3400: Check for device status only onceGwendal Grignou2021-02-251-28/+31
| | | | | | | | | | | | | | | | | | Since ASIEN (interrupt on ALS saturation) and ALS threshold interrupts are disabled, we can only get interrupt on RBGC cycle read. Therefore, when using the interrupt, not need to check if RGB data is ready in post_events(). Only check while in force mode. Remove recheck when accounting for saturation. BUG=b:177860358 BRANCH=kukui,hatch,puff,volteer TEST=compile Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Change-Id: I7fc419a98828b9b188849e04a15cfefaf9e96c8a Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2572739 Reviewed-by: Nick Vaccaro <nvaccaro@google.com>
* Zephyr: Create public headers for bmi260, bma2x2, and tcs3400Hyungwoo Yang2021-01-201-1/+1
| | | | | | | | | | | | | | | Separate out the public part of sensor headers so it can be included from Zephyr. BUG=b:175434113 BRANCH=none TEST=make buildall -j8 build volteer on zephyr Signed-off-by: Hyungwoo Yang <hyungwoo.yang@intel.corp-partner.google.com> Change-Id: I899e9aea99d6c7d56a1b6735538b280fe0735313 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2637251 Reviewed-by: Jack Rosenthal <jrosenth@chromium.org>
* task_set_event: remove the wait argumentDawid Niedzwiecki2020-12-141-3/+2
| | | | | | | | | | | | | | | | | | | | There is an option in the task_set_event function which force the calling task to wait for an event. However, the option is never used thus remove it. This also will help in the Zephyr migration process. BUG=b:172360521 BRANCH=none TEST=make buildall Signed-off-by: Dawid Niedzwiecki <dn@semihalf.com> Change-Id: Ic152fd3d6862d487bcc0024c48d136556c0b81bc Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2521599 Reviewed-by: Jett Rink <jettrink@chromium.org> Reviewed-by: Tom Hughes <tomhughes@chromium.org> Reviewed-by: Jack Rosenthal <jrosenth@chromium.org> Commit-Queue: Jack Rosenthal <jrosenth@chromium.org>
* driver: tcs3400: Report ODR for RGB sensorGwendal Grignou2020-12-081-5/+5
| | | | | | | | | | | | | | | | | | To be able to send data to the host, the oversampling ratio must be non-zero. It implies: - the host send a set frequency request for the RGB sensor - the EC use the frequency from the clear sensor to calculate the RGB sensor oversampling ratio BUG=b:172343923 BRANCH=kukui,hatch,volteer TEST=On Volteer, in calibration mode, check we get samples from the RGB sensor. Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Change-Id: I70eb62287cae983800cdadaee4cfe00b2f22b734 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2570825 Reviewed-by: Nick Vaccaro <nvaccaro@google.com>
* driver: tcs3400: In calibration mode: always send dataGwendal Grignou2020-12-081-7/+9
| | | | | | | | | | | | | | When in calibration mode, send data periodically, even when measurement is identical to the previous one. BUG=b:172343923 TEST=On Volteer, check data is coming periodically. BRANCH=kukui,hatch,volteer Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Change-Id: I31da6edcf5d175812697b99b7e7ef6ec85497770 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2570824 Reviewed-by: Nick Vaccaro <nvaccaro@google.com>
* driver:tcs3400: Add placeholder set_rangeGwendal Grignou2020-11-231-0/+8
| | | | | | | | | | | | | | | | | | set_range is now called all the time at init to set the current range at resume. Set one for tcs3400 otherwise the EC crashes. fixes: commit d28c10498cd ("motion_sense: Make change in range permanenti") CL:2215751 BUG=chromium:1083791 BRANCH=none TEST=check on Volteer EC is not crashing in motion_sense_switch_sensor_rate() at resume. Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Change-Id: I172d3289bb69c14fa757d761b0099fea312292e0 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2553346 Reviewed-by: Ching-Kang Yen <chingkang@chromium.org>
* motion_sense: Make change in range permanentGwendal Grignou2020-11-121-12/+5
| | | | | | | | | | | | | | | | | | | | | | | | | When AP changes range, unlike offset or ODR, it was not surviving init() call. If the sensor is powered off in S3, at resume the range would be back to the default. To make it consistent with other attributes, remember range change until EC powers down. - remove get_range - add current_range to store the range currently used. This is modifiable by the AP - when the AP shutdown, revert current_range to default_range - Remove const attribute for sensor structure when init and set_range is called. BUG=chromium:1083791 BRANCH=none TEST=One eve branch, check range is preserved even after 'shutdown -h 0' Change-Id: Ia7126ac0cc9c3fef60b4464d95d6dd15e64b0fc4 Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2215751 Reviewed-by: Yuval Peress <peress@chromium.org>
* drivers/tcs3400: code cleanups in transferring sensor valuesIkjoon Jang2020-09-021-62/+49
| | | | | | | | | | | | | | | | - bugfix in using memcpy() for unmatched size - use clamp helper functions in tcs3400's transferring 32 bit values into 16bit unsigned packet. - use IS_ENABLED() instead of ifdef/endif macros BUG=b:162396219 TEST=Reading illuminance values from kukui kernel BRANCH=none Signed-off-by: Ikjoon Jang <ikjn@chromium.org> Change-Id: Icc781e0ec6f4eb3465069a697aad8e8e16b9a9a2 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2328950 Reviewed-by: Gwendal Grignou <gwendal@chromium.org>
* drivers/tcs3400: don't apply zero scale.Jongpil Jung2019-12-271-0/+4
| | | | | | | | | | | | | | | | | EC will be broken with scale zero. So, we need to check scale value before we apply value. BUG=b:146868237 TEST=emerge-hatch chromeos-ec and flash ec on device. apply zero scale into rgb sensor. (clear, red, green and blue) echo "0" > /sys/bus/iio/devices/iio\:device6/in_illuminance_calibscale BRANCH=none Change-Id: I716ae805ff1742ddd45dbbdfd956beb1c22d5a6c Signed-off-by: Jongpil Jung <jongpil19.jung@samsung.corp-partner.google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1982294 Reviewed-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-by: Nick Vaccaro <nvaccaro@google.com>
* drivers/tcs3400: don't add offset for LUXNick Vaccaro2019-12-121-2/+23
| | | | | | | | | | | | | | | | When translating RGB to XYZ, don't add in the offset value for LUX. BUG=b:144319657 BRANCH=NONE TEST="make -j BOARD=kohaku", flash EC on kohaku, place kohaku in a dark location and verify it reads 0. Change-Id: I4c6dcc01999ca5e4390f97c31e50b27075ed9ce4 Signed-off-by: Nick Vaccaro <nvaccaro@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1959458 Tested-by: Mengqi Guo <mqg@chromium.org> Reviewed-by: Gwendal Grignou <gwendal@chromium.org>
* drivers/tcs3400: add IR scaling factorNick Vaccaro2019-12-121-8/+14
| | | | | | | | | | | | | | | | | | | | | | | | This change adds a new scaling factor used in IR separation that further improves sensor CCT accuracy. The following restructure of calibration structure was required : - renamed rgb_calibration_t struct to rgb_channel_calibration_t - added new rgb_calibration_t structure definition to include new irt scaling factor to the rgb calibration structure BUG=b:143246741 BRANCH=master TEST=none Cq-Depend: chromium:1879189 Change-Id: Idb3325be828e8ed15747144670230963c369a461 Signed-off-by: Nick Vaccaro <nvaccaro@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1879188 Tested-by: Mengqi Guo <mqg@chromium.org> Reviewed-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-by: Mengqi Guo <mqg@chromium.org> Reviewed-by: Scott Collyer <scollyer@chromium.org>
* drivers/tcs3400: fix a couple values in lux tableNick Vaccaro2019-09-091-5/+5
| | | | | | | | | | | | | | | | | | | | | | A couple of the values in the lux atime table needed adjusting as they were too aggressive and were causing train-up / saturate / train-down / repeat... pattern cycles. Allow device to upshift in training when we're >= 2.5x from saturation (was >= 3x). Fixed a couple of nits. BUG=b:139749448 BRANCH=master TEST=Walked a flapjack through each lux light level, with a test at the low end of the level and a test at the high end of each level (i.e. for LUX level 1000, tested at 1100 and 1900 LUX), assure the tcs3400 doesn't go into saturation while trying to hit the 90% band. Change-Id: I84c5bf09e072e96d516d91520a176fa35274ce7a Signed-off-by: Nick Vaccaro <nvaccaro@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1767598
* config: Refactor CONFIG_ACCEL_FIFO to enable use of IS_ENABLEDYuval Peress2019-09-031-10/+8
| | | | | | | | | | | | | | | This change allows us to use the IS_ENABLED condition to replace the various ifdef guards around the CONFIG_ACCEL_FIFO BUG=b:137758297,chromium:981990 BRANCH=None TEST=buildall and CTS tests on Arcada Change-Id: I65d36bac19855e51c830a33e6f3812575e8d15d9 Signed-off-by: Yuval Peress <peress@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1704164 Reviewed-by: Jack Rosenthal <jrosenth@chromium.org> Reviewed-by: Gwendal Grignou <gwendal@chromium.org>
* common: Move fifo logic out of motion_sense.cYuval Peress2019-08-231-0/+1
| | | | | | | | | | | | | | | | | | | | This change is needed to allow better testing of the fifo behavior. Additionally, motion_sense_fifo.c will only be compiled if CONFIG_ACCEL_FIFO is defined. This behaviour requires a few small changes to several boards and baseboards to make sure that we only define CONFIG_ACCEL_FIFO when the MOTIONSENSE task is present (some times that may be only in one section RW or RO). BUG=b:137758297 BRANCH=None TEST=buildall and ran CTS on arcada Change-Id: I2f7e4e436ba9568a35b7a0b2c8d53a73f198ba73 Signed-off-by: Yuval Peress <peress@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1704163 Reviewed-by: Alexandru M Stan <amstan@chromium.org> Commit-Queue: Alexandru M Stan <amstan@chromium.org>
* driver/tcs3400: improve efficiency of auto-adjustNick Vaccaro2019-08-201-16/+60
| | | | | | | | | | | | | | | | | | | | | | | | | | Adds an array which holds the number of atime increments needed at various lux levels and again settings to change delta from saturation by 1%. Using this table, the anti-saturation algorithm can get to the 90% band in most cases in a single adjustment vs the 10 to 15 adjustments previously needed when not using this table. Enabling CONFIG_TCS_USE_LUX_TABLES takes up 280 bytes in the ec.obj. BUG=b:124512628 BRANCH=master TEST=Flash and boot flapjack, verify that ALS and RGB sensors are still generating data. I used alslog patch and enabled ALS logging in EC console via "alslog 2047". Verify that under a constant light source, the adjustment mechanism correctly drives the ALS values such that they land in the sweet spot between 90 to <100% of saturation. Change-Id: I7cd0b8242e72233f50ff2751834f7bba367c6706 Signed-off-by: Nick Vaccaro <nvaccaro@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1677764 Reviewed-by: Gwendal Grignou <gwendal@chromium.org>
* driver/tcs3400: add auto-compensation for saturationNick Vaccaro2019-08-201-122/+353
| | | | | | | | | | | | | | | | | | | | | | | | | | Making settings more sensitive makes the SNR better, so this algorithm strives to keep the output level as close to 90% saturation as possible. Adds calibration mode and lux calculation. Removes unused last_value field from the tcs3400_rgb_drv_data_t structure, we use raw_xyz field in motion_sensor_t struct instead. BUG=b:124512628 BRANCH=master TEST=Flash and boot flapjack, verify that ALS and RGB sensors are still generating data. I used alslog patch and enabled ALS logging in EC console via "alslog 1023". Verify that under a constant light source, the adjustment mechanism correctly drives the ALS values such that they land in the sweet spot between 90 to <100% of saturation. Cq-Depend: chromium:1711958,chromium:1702543 Change-Id: Ibf260a990fe285cb54ee94c1ebe8aa85ea10affc Signed-off-by: Nick Vaccaro <nvaccaro@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1633269 Reviewed-by: Gwendal Grignou <gwendal@chromium.org>
* Remove __7b, __8b and __7bfDenis Brockus2019-07-201-3/+3
| | | | | | | | | | | | | | | | | | | The extentions were added to make the compiler perform most of the verification that the conversion was being done correctly to remove 8bit addressing as the standard I2C/SPI address type. Now that the compiler has verified the code, the extra extentions are being removed BUG=chromium:971296 BRANCH=none TEST=make buildall -j TEST=verify sensor functionality on arcada_ish Change-Id: I36894f8bb9daefb5b31b5e91577708f6f9af2a4f Signed-off-by: Denis Brockus <dbrockus@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1704792 Reviewed-by: Jack Rosenthal <jrosenth@chromium.org>
* Use 7bit I2C/SPI slave addresses in ECDenis Brockus2019-07-191-4/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Opt for 7bit slave addresses in EC code. If 8bit is expected by a driver, make it local and show this in the naming. Use __7b, __7bf and __8b as name extensions for i2c/spi addresses used in the EC codebase. __7b indicates a 7bit address by itself. __7bf indicates a 7bit address with optional flags attached. __8b indicates a 8bit address by itself. Allow space for 10bit addresses, even though this is not currently being used by any of our attached devices. These extensions are for verification purposes only and will be removed in the last pass of this ticket. I want to make sure the variable names reflect the type to help eliminate future 7/8/7-flags confusion. BUG=chromium:971296 BRANCH=none TEST=make buildall -j Change-Id: I2fc3d1b52ce76184492b2aaff3060f486ca45f45 Signed-off-by: Denis Brockus <dbrockus@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1699893 Reviewed-by: Jack Rosenthal <jrosenth@chromium.org>
* driver/tcs3400: make error message in sensor read less spammy.Ting Shen2019-07-181-2/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | In EMULATED_IRQ_EVENT mode, we try to estimate the time between a read request and data ready. If the estimated time is shorter, an error message is printed to the console on every retry. On Kukui, this caused ec console spamming one line per second. Change the behavior to print only when returning error. No need to adjust the estimate time because one retry per read is still good enough. BUG=b:137345336 TEST=manually, verify that error message disappeared. BRANCH=None Change-Id: Ie85e8f1a80ea36ca5c50f57a19eba35f3f79f86d Signed-off-by: Ting Shen <phoenixshen@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1697889 Tested-by: Fei Shao <fshao@chromium.org> Commit-Queue: Ting Shen <phoenixshen@chromium.org> Reviewed-by: Nick Vaccaro <nvaccaro@chromium.org> Reviewed-by: Nick Vaccaro <nvaccaro@google.com> Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
* driver: add an option to emulate irq event in TCS3400Ting Shen2019-06-251-6/+30
| | | | | | | | | | | | | | | | | Krane does not reserve an interrupt pin for ALS, so we need another way to trigger the irq handler. Add a new config option CONFIG_ALS_TCS3400_EMULATED_IRQ_EVENT to support this use case. BUG=b:129419982 BRANCH=None TEST=verify that `accelread 3` outputs reasonable data on krane. Change-Id: I960df249d29c0ac21810057e25f14d4bac3e14f5 Signed-off-by: Ting Shen <phoenixshen@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1621449 Reviewed-by: Nick Vaccaro <nvaccaro@google.com> Commit-Queue: Ting Shen <phoenixshen@chromium.org> Tested-by: Ting Shen <phoenixshen@chromium.org>
* driver/tcs3400: disable ADC & oscillator between readsNick Vaccaro2019-06-141-14/+9
| | | | | | | | | | | | | | | | | | | | Disabling ADC and oscillator after servicing the interrupt not only saves power, but it assures the next light sample gathered will be based on a single again and atime setting. Without disabling ADC and oscillator, part of the next sample was getting sampled at one again and atime setting, but part of that sample was getting sampled using a different again or atime setting in cases where the saturation compensation mechanism changed again or atime. BUG=b:134188019 BRANCH=master TEST=Flash and boot flapjack, verify that ALS and RGB sensors are still generating data (I used alslog patch and enabled logging in EC console via "alslog" command). Change-Id: Ie599e03e1e5d8a1956a7006cc944a51dd759e8a6 Signed-off-by: Nick Vaccaro <nvaccaro@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1633270
* common: motion_sense: Spread timestamps in motion sense fifoYuval Peress2019-06-061-3/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | This changes moves the specialized logic for timestamp spreading away from the accelgyro_lsm6dsm and into the main motion_sense loop. The motion_sense_fifo_add_data function was replaced by a stage equivalent, and a commit function was added. Similarly, internal static functions for motion_sense.c were renamed to use the stage terminology. The idea is: When a sensor is read, it might provide more than one measurement though the only known timestamp is the one that caused the interrupt. Staging this data allows us to use the same fifo queue space that the entries would consume eventually anyway without making the entries readable. Upon commit, the timestamp entries are spread if needed. Note that if tight timestamps are disabled, the commit becomes a simple tail move. BUG=chromium:966506 BRANCH=None TEST=Ran CTS on arcada. Change-Id: Ib7d0a75c9c56fc4e275aed794058a5eca58ff47f Signed-off-by: Yuval Peress <peress@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1637416 Reviewed-by: Jack Rosenthal <jrosenth@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org>
* motionsense: Convert in_spoof_mode to a more generic flagsYuval Peress2019-05-231-3/+3
| | | | | | | | | | | | BUG=b:129159505 BRANCH=arcada TEST=I ran `make buildall` since this change isn't used yet it doesn't affect run-time behavior. Change-Id: I01857d679b800f9b53762c659ebd9a018cbf16db Signed-off-by: Yuval Peress <peress@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1612251 Legacy-Commit-Queue: Commit Bot <commit-bot@chromium.org>
* tcs3400: rename tcs3400_drv_data_t to als_drv_data_tNick Vaccaro2019-05-091-19/+19
| | | | | | | | | | | | | | | | | | | - 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>
* driver: add tcs3400 RGB channel sensor driverNick Vaccaro2019-05-071-2/+162
| | | | | | | | | | | | | | | | | | | Implements a MOTIONSENSE_TYPE_LIGHT_RGB sensor using the tcs3400. BUG=b:129419982 BRANCH=master CQ-DEPEND=CL:1541955 TEST=cherry-pick CLs to enable tcs3400 for flapjack and to add alslog, build and flash to flapjack; boot flapjack, from ec console, execute 'sysjump rw', then execute "alslog" to enable logging of als data. Verify als data is generated and logged to ec console. Change-Id: Ia8000d27ff4f9683ceb4c9522bc7f0fed20c2045 Signed-off-by: Nick Vaccaro <nvaccaro@google.com> Reviewed-on: https://chromium-review.googlesource.com/1551748 Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com> Reviewed-by: Gwendal Grignou <gwendal@chromium.org>
* driver: add tcs3400 ALS sensor chip driverNick Vaccaro2019-05-061-0/+312
Implements a MOTIONSENSE_TYPE_LIGHT sensor using the clear channel of the tcs3400. BUG=b:124512628 BRANCH=master TEST=cherry-pick CLs to enable tcs3400 for flapjack and to add alslog, build and flash to flapjack; boot flapjack, from ec console, execute 'sysjump rw', then execute "alslog" to enable logging of als data. Verify als data is generated and logged to ec console. Change-Id: I918cbf5513fb5eba20a27705c47545d3c0b3ca91 Signed-off-by: Nick Vaccaro <nvaccaro@google.com> Reviewed-on: https://chromium-review.googlesource.com/1541955 Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com> Tested-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-by: Gwendal Grignou <gwendal@chromium.org>