summaryrefslogtreecommitdiff
path: root/driver
Commit message (Collapse)AuthorAgeFilesLines
* driver: bmi160 Add code for calibrationGwendal Grignou2015-07-154-50/+191
| | | | | | | | | | | | | | | | | | | | | | | | Add code for set/getting calibration data on bmi160 Add code to perform FOC (Fast Online Calibration) on bmi160. Add delay after getting out of suspend to be sure sensor is available. BRANCH=smaug TEST=Check sensors are properly calibrated on Smaug: Perform calibration: echo 1 > /sys/bus/iio/devices/iio:device1/calibrate Read calibration values: cat /sys/bus/iio/devices/iio:device1/*_calibbias Check the values are translated properly. Write calibration values and check it affects the sensor output. BUG=chromium:506101,chrome-os-partner:39900 Change-Id: Ib9aad9bbd90b4249625641d68febf94b69aa4987 Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/283165 Reviewed-by: Alec Berg <alecaberg@chromium.org>
* driver: bmi160: Add FIFO and interrupt supportGwendal Grignou2015-07-102-81/+421
| | | | | | | | | | | | | | | | | | | Add FIFO support, where bmi160 hardware FIFO is copied in local fifo. Add rudimentary support for single/double tap and lift detection. BUG=chrome-os-partner:39900 BRANCH=smaug TEST=Check on F411 that FIFO data is retrieved and correct. Check on Smaug as well, with proper kernel the collect the FIFO: - check that increasing sampling_frequency we are collecting the FIFO less often - check no frames are lost. - check tap/lift interrupts are working - if latency is less than 100ms, check we are collecting much faster. Change-Id: Ic2317c27fad0ef31dacd6e18cd5f71ccd2cec807 Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/274227
* driver: bm160: fix ODR_TO_REG macrosGwendal Grignou2015-07-101-3/+7
| | | | | | | | | | | | | Were not working when ODR > 100Hz. BRANCH=smaug TEST=Check by setting iio:deviceX/frequency from user space. BUG=chrome-os-partner:39900 Change-Id: I1795e4faf85039133da6bb38ae3b415e5fde236e Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/284612 Reviewed-by: Alec Berg <alecaberg@chromium.org>
* driver: lsm6ds0: Add bias offset codeGwendal Grignou2015-07-092-32/+47
| | | | | | | | | | | | | | | | Add code to store bias from AP at boot and correct raw data from accelerometer on the fly. Also return the raw data on 16 bits, as recommned by sysfs. BRANCH=smaug BUG=chromium:506101 TEST=check set and get offset works fine. Check value from accelerometer are sane (on Samus). Change-Id: Ia62f02aadb9e11988edf0049a0cfee817641db88 Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/283163 Reviewed-by: Alec Berg <alecaberg@chromium.org>
* driver: kxcj9: Add bias offset codeGwendal Grignou2015-07-092-31/+46
| | | | | | | | | | | | | | | Add code to store bias from AP at boot and correct raw data from accelerometer on the fly. Also return the raw data on 16 bits, as recommned by sysfs. BRANCH=smaug BUG=chromium:506101 TEST=check set and get offset works fine. Check value from accelerometer are sane (on Samus). Change-Id: I2ad4ce601665b497527dc8c6acb6e7d398366afe Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/283162
* bq2598x: ryu: take into account hardware input current optimizerVincent Palatin2015-07-012-0/+33
| | | | | | | | | | | | | | | | | | | | | | | | Take profit of the hardware input current ramping/back-off integrated in the BQ2589x charger by setting the current limits higher for BC1.2 USB modes and letting the hardware adjust to the actual charger limitation depending on the VBUS voltage droop. Signed-off-by: Vincent Palatin <vpalatin@chromium.org> BRANCH=smaug BUG=chrome-os-partner:42045 TEST=Connect a Nexus 9 DCP charger to Smaug and see the input current adjusted to 1650mA without brown-out, read back the value properly from the AP: $ ectool usbpdpower Port 0: SNK Charger DCP 4958mV / 1650mA, max 5000mV / 1650mA / 8250mW Change-Id: I348e5ee4980a5652f72f279ab4e3a7126583b093 Reviewed-on: https://chromium-review.googlesource.com/282584 Trybot-Ready: Vincent Palatin <vpalatin@chromium.org> Tested-by: Vincent Palatin <vpalatin@chromium.org> Reviewed-by: Alec Berg <alecaberg@chromium.org> Commit-Queue: Vincent Palatin <vpalatin@chromium.org>
* tcpc: use initialization complete alert bit to signal readinessAlec Berg2015-06-301-3/+7
| | | | | | | | | | | | | | | Use the new TCPC initialization complete bit in alert register to signal TCPC readiness instead of checking for USB VID to be set. BUG=none BRANCH=none TEST=load on glados, make sure we can boot without battery. Change-Id: I4b25c973ece0de6dd3f419c5901cff1d8d05ed95 Signed-off-by: Alec Berg <alecaberg@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/282593 Reviewed-by: Scott Collyer <scollyer@chromium.org> Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* usb_mux: Add support for Parade PS8740 chipShawn Nematbakhsh2015-06-303-0/+150
| | | | | | | | | | | | | | | Initial support for Parade PS8740 Type-C redriving switch. BUG=chrome-os-partner:41696 TEST=Manual on Glados in subsequent commit. Verify set() and get() functions set and return consistent values. Verify that USB SS device functions when muxes are set to dock or USB. BRANCH=None Change-Id: Iedbe53cc76f30ecd969c2ca99a7377ed3b193729 Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/282280 Reviewed-by: Alec Berg <alecaberg@chromium.org>
* usb_mux: Add driver interface for USB-C muxesShawn Nematbakhsh2015-06-305-99/+267
| | | | | | | | | | | | | | | | | | | | In preparation for adding support for additional USB-C mux chips, add a new high-level USB-C mux interface usb_mux.c. usb_mux functions are now called from pd code instead of board-level functions. usb_mux calls down into a mux chip-specific driver (currently pi3usb30532) or board-specific drivers which toggle GPIOs (for legacy boards). BUG=chrome-os-partner:41696 TEST=Manual on Glados in subsequent commit. Verify set() and get() functions set and return consistent values. Verify that USB SS device functions when muxes are set to dock or USB. Also, verify that DP dongle and USB SS device are functional on both PD ports on samus_pd. BRANCH=None Change-Id: Ib6477f489310f3be1430585ea09fea26f57e3752 Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/281435 Reviewed-by: Alec Berg <alecaberg@chromium.org>
* tcpc: update tcpci registers to latest specAlec Berg2015-06-303-32/+47
| | | | | | | | | | | | | | | Update TCPCI registers to version 0.62 of PD Interface specification. BUG=none BRANCH=none TEST=test on glados and samus Change-Id: I57338b385123371e90f3b79b84e652af15be1bf1 Signed-off-by: Alec Berg <alecaberg@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/282067 Reviewed-by: Scott Collyer <scollyer@chromium.org> Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* pd: refactor tcpm and move alert function to tcpm driverAlec Berg2015-06-303-17/+193
| | | | | | | | | | | | | | | Refactor the tcpm/tcpc split such that the tcpm driver implements the alert functionality since it may be unique for different tcpc chips. BUG=chrome-os-partner:41842 BRANCH=none TEST=make -j buildall. run on samus and glados. Change-Id: I23f2d7f8627d5337b8d001a09bf27622be24fe33 Signed-off-by: Alec Berg <alecaberg@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/281631 Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* pd: create driver/tcpm/ to hold TCPM driversAlec Berg2015-06-243-0/+286
| | | | | | | | | | | | | | | | Create driver/tcpm/ folder to hold TCPM drivers. Currently the two drivers are a stub driver which is used when TCPM and TCPC are on the same MCU and can make direct calls between the two and the TCPCI driver which implements the standard TCPCI protocol. BUG=chrome-os-partner:41842 BRANCH=none TEST=make -j buildall Change-Id: Ie4d9b36eb33155254f8b87b83861f98a7a80693a Signed-off-by: Alec Berg <alecaberg@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/281630 Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* bq2589x: ryu: enable IR compensationVincent Palatin2015-06-242-0/+33
| | | | | | | | | | | | | | | | | | | | | | Set the resistance compensation for the charger IC according to the EE team measurements : - Resistance compensation = 60 mOhm - Voltage clamping = 160 mV - Thermal regulation = 120C Signed-off-by: Vincent Palatin <vpalatin@chromium.org> BRANCH=smaug BUG=chrome-os-partner:38603 TEST=dump the BQ25892 registers by using the "bq25" command and see that REG08 contains 0x77. Change-Id: I90e9ea4569d77fd90ed0290ec78e66810d744648 Reviewed-on: https://chromium-review.googlesource.com/281660 Tested-by: Vincent Palatin <vpalatin@chromium.org> Reviewed-by: Alec Berg <alecaberg@chromium.org> Commit-Queue: Vincent Palatin <vpalatin@chromium.org> Trybot-Ready: Vincent Palatin <vpalatin@chromium.org>
* cleanup: fix all the header guardsBill Richardson2015-06-1822-64/+64
| | | | | | | | | | | | | | | This unifies all the EC header files to use __CROS_EC_FILENAME_H as the include guard. Well, except for test/ util/ and extra/ which use __TEST_ __UTIL_ and __EXTRA_ prefixes respectively. BUG=chromium:496895 BRANCH=none TEST=make buildall -j Signed-off-by: Bill Richardson <wfrichar@chromium.org> Change-Id: Iea71b3a08bdec94a11239de810a2b2e152b15029 Reviewed-on: https://chromium-review.googlesource.com/278121 Reviewed-by: Randall Spangler <rspangler@chromium.org>
* bq2589x: fix typo in voltage selectionVincent Palatin2015-06-181-1/+1
| | | | | | | | | | | | | | | | | | Use the right rounding function for the charging voltage selection. Signed-off-by: Vincent Palatin <vpalatin@chromium.org> BRANCH=smaug BUG=chrome-os-partner:41594 TEST=On Smaug EVT2, check that the battery is charging to 100% and compare the voltage requested by the battery (using "battery" command) to the voltage set by using "charger" command. Change-Id: Ic5076f23242d1fac31ad34e0c8c9bfe0a868a91e Reviewed-on: https://chromium-review.googlesource.com/278260 Reviewed-by: Alec Berg <alecaberg@chromium.org> Commit-Queue: Vincent Palatin <vpalatin@chromium.org> Tested-by: Vincent Palatin <vpalatin@chromium.org>
* accel: Fix BMM150 init sequenceGwendal Grignou2015-06-131-2/+4
| | | | | | | | | | | | | | | Without this change, after a while, the data from the accelerometer is garbled, weaker than expected. BUG=chromium:494270 TEST=Check that with this change, the accelerometer vector is always around 1G. BRANCH=smaug Change-Id: I9bb4acd208e8fa4111fc91e35c4cb5636f9425f4 Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/276666 Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* usb: pi3usb9281: Allow flexible chip configurationsShawn Nematbakhsh2015-06-122-102/+94
| | | | | | | | | | | | | | | | | | Previously we supported using a single pi3usb9281 chip, or using two chips on the same i2c bus behind a mux. Now that we need to support a third configuration of multiple chips on different busses, it makes sense to be able to configure the configuration freely at the board level. BUG=chrome-os-partner:40920 TEST=Manual on samus_pd. Plug USB charger, verify detection is correct on both charge ports. BRANCH=None Change-Id: I120dcb1c3ceb6f013b92407effcd8cb66e7ffcce Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/276511 Reviewed-by: Alec Berg <alecaberg@chromium.org>
* mcdp28x0: Add more useful error codes.Todd Broch2015-06-112-31/+60
| | | | | | | | | | | | | | BRANCH=samus BUG=none TEST=compiles Signed-off-by: Todd Broch <tbroch@chromium.org> Change-Id: Id925acbafcb49dbf503f666a7edb79b7eb25fecd Reviewed-on: https://chromium-review.googlesource.com/276554 Reviewed-by: Alec Berg <alecaberg@chromium.org> Commit-Queue: Todd Broch <tbroch@chromium.org> Tested-by: Todd Broch <tbroch@chromium.org>
* Stream: Remove in_stream/out_stream interfaceAnton Staaf2015-06-111-8/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | The in_stream and out_stream interfaces were a first attempt at providing an abstraction for multiple stream like devices (usart, USB, I2C/LPC host interfaces...). But, by baking the queue into the device it proved to be hard to use and required additional resources (task or deferred hook) to handle passing data from one stream to another. Since then the queue policy and producer/consumer interfaces have replaced the stream interfaces. This CL removes the old stream interfaces and updates the only users (deleting the test echo code from the discovery-stm32f072 board and updating the mcdp28x0 driver to use the queue interfaces). Signed-off-by: Anton Staaf <robotboy@chromium.org> BRANCH=None BUG=None TEST=make buildall -j Change-Id: Ic0d2abf81eafc4fb2e61172540151f2d0ba45caf Reviewed-on: https://chromium-review.googlesource.com/276163 Reviewed-by: Todd Broch <tbroch@chromium.org> Commit-Queue: Anton Staaf <robotboy@chromium.org> Trybot-Ready: Anton Staaf <robotboy@chromium.org> Tested-by: Anton Staaf <robotboy@chromium.org>
* Remove obsolete board-specific codeRandall Spangler2015-06-102-141/+0
| | | | | | | | | | | | | | | | | Now that we've removed boards from ToT, also delete board-specific code used only by the removed boards. There are still more things to remove (unused charging chips, LED drivers, COMx support). More CLs coming. BUG=chromium:493866 BRANCH=none TEST=make buildall -j Change-Id: Ie6bdeaf96e61cadd77e3f6336c73b9b54ff4eabb Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/276524 Reviewed-by: Alec Berg <alecaberg@chromium.org>
* charger: Add Intersil charger ISL9237Rong Chang2015-06-083-0/+484
| | | | | | | | | | | | | | | | | | | | | | | ISL9237 is a buck-boost narrow output voltage DC charger. This change provides interfaces to satisfy external dependencies for charge_state_v2. ISL9237's charging voltage control is different from smart battery chargers. And there's no SBC compatible charging mode and status. So this CL modified charger_set_voltage() behavior by controlling VSYS voltage. BRANCH=none BUG=none TEST=ran on reworked glados Signed-off-by: Rong Chang <rongchang@chromium.org> Change-Id: Ibbbf805bbbe1ee06f87a41cde3e39acbf2e105b4 Reviewed-on: https://chromium-review.googlesource.com/272882 Reviewed-by: Alec Berg <alecaberg@chromium.org> Commit-Queue: Aaron Durbin <adurbin@chromium.org> Trybot-Ready: Aaron Durbin <adurbin@chromium.org> Tested-by: Aaron Durbin <adurbin@chromium.org>
* mcdp28x0: Use custom appstest command for get_infoTodd Broch2015-05-301-13/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Firmware's original get_info command always returns the same values for family, chipid, irom & fw despite indeed having different versions. Currently its: family:000e chipid:0001 irom:1.0.0 fw:0.0.0 As we have a new stepping of the chip ('BB') and a corresponding new firmware (>=0.74) we need a mechanism to verify and log this change. CL uses the newly hatched appstest command (0x12) message 0x28 to surface information that properly reflects both hardware and firmware running. Signed-off-by: Todd Broch <tbroch@chromium.org> BRANCH=samus BUG=chrome-os-partner:35939 TEST=manual, For devices running 0.54 | 0.74 fw see gpio MCDP_READY asserted. With CONFIG_CMD_MCDP in board/hoho/board.h see the following responses when executing 'mcdp info' Stepping | FW | Response -------------------------------------------------------------------- 'BA' 0.53 fails as expected 'BA' 0.54 family:0010 chipid:2850 irom:2.0.0 fw:0.54.0 'BB' 0.73 fails as expected 'BB' 0.74 family:0010 chipid:2850 irom:2.1.0 fw:0.74.0 Change-Id: I2c36393a298c617f903389dab24da631b60ec574 Reviewed-on: https://chromium-review.googlesource.com/274049 Reviewed-by: Scott Collyer <scollyer@chromium.org> Commit-Queue: Todd Broch <tbroch@chromium.org> Tested-by: Todd Broch <tbroch@chromium.org>
* mcdp28x0: add appstest console command.Todd Broch2015-05-302-3/+66
| | | | | | | | | | | | | | | | Signed-off-by: Todd Broch <tbroch@chromium.org> BRANCH=samus BUG=chrome-os-partner:35939 TEST=manual, with CONFIG_CMD_MCDP in board/hoho/board.h Try appstest commands on hoho and see them work. Change-Id: I0b3f674251f0d7c68ba4958fd3376b7c8d81b13f Reviewed-on: https://chromium-review.googlesource.com/272792 Reviewed-by: Scott Collyer <scollyer@chromium.org> Commit-Queue: Todd Broch <tbroch@chromium.org> Tested-by: Todd Broch <tbroch@chromium.org>
* oak: add initial support for oak board rev1Rong Chang2015-05-273-0/+164
| | | | | | | | | | | | | | | Add initial support for Oak rev1 board. This is just the EC and includes battery charging but does not include USB PD. BUG=none BRANCH=none TEST=load on oak board and get console Signed-off-by: Rong Chang <rongchang@chromium.org> Signed-off-by: Alec Berg <alecaberg@chromium.org> Change-Id: I626f3921025fbc39ba22b04eeb6dd1084cd70777 Reviewed-on: https://chromium-review.googlesource.com/261678
* Producer/Consumer: Refactor to use Queue policiesAnton Staaf2015-05-261-13/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Previously the Producer and Consumer interfaces tracked the Consumer and Producer respectively at the other end of the queue that they interacted with. This was done to avoid modifying the queue implementation, but resulted in a rougher interface that required additional initialization steps and prevented alternative configurations; many producers and one consumer for example. This commit uses the new queue policies to track this information. The new direct policy behaves as the old producer and consumers did. Now the producers and consumers are just named references to the queue that they work on and a convenient location for a notification callback when the queue is updated in a way that is relevent to the producer or consumer. All users of Producer and Consumer have been updated including the stream adaptors which are in use by the echo test code and the mcdp28x0 driver. Use of the stream adaptors has also been simplified. Signed-off-by: Anton Staaf <robotboy@chromium.org> BRANCH=None BUG=None TEST=make buildall -j Manual testing of Ryu (P5) and discovery board echo task Change-Id: I704be6378a31b4e20f5063295eff9943e4900409 Reviewed-on: https://chromium-review.googlesource.com/271792 Reviewed-by: Anton Staaf <robotboy@chromium.org> Commit-Queue: Anton Staaf <robotboy@chromium.org> Trybot-Ready: Anton Staaf <robotboy@chromium.org> Tested-by: Anton Staaf <robotboy@chromium.org>
* Queue: Add policies to queuesAnton Staaf2015-05-261-2/+2
| | | | | | | | | | | | | | | | | | | | Policies give a convenient place to hook into the queue operations and notify something that there is new space free in the queue or new units added. Signed-off-by: Anton Staaf <robotboy@chromium.org> BRANCH=None BUG=None TEST=make buildall -j Change-Id: I94b2aa94b8e8d07911191bc19a39fa827623b117 Reviewed-on: https://chromium-review.googlesource.com/271791 Reviewed-by: Bill Richardson <wfrichar@chromium.org> Reviewed-by: Anton Staaf <robotboy@chromium.org> Commit-Queue: Anton Staaf <robotboy@chromium.org> Trybot-Ready: Anton Staaf <robotboy@chromium.org> Tested-by: Anton Staaf <robotboy@chromium.org>
* mcdp28x0: Add devid console command.Todd Broch2015-05-222-7/+39
| | | | | | | | | | | | | | | | | | BRANCH=samus BUG=chrome-os-partner:35939 TEST=manual, with CONFIG_CMD_MCDP in board/hoho/board.h > mcdp devid 0 devid[0] = BOBCAT > mcdp devid 1 devid[1] = ST > mcdp devid 2 devid[2] = IROM Change-Id: I82938975be55bb924ced06e9d0a35f03dc47ae99 Signed-off-by: Todd Broch <tbroch@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/272693 Reviewed-by: Alec Berg <alecaberg@chromium.org>
* mcdp28x0: Add info console command.Todd Broch2015-05-221-6/+32
| | | | | | | | | | | | | | | | | | | | | | | | Would be useful to expose more of the GProbe commands to developers who have access to boards console (hoho, honeybuns). This CL adds a console command and seeds it the 'mcdp info' command. Signed-off-by: Todd Broch <tbroch@chromium.org> BRANCH=samus BUG=chrome-os-partner:35939 TEST=manual, with CONFIG_CMD_MCDP defined in board/hoho/board.h - Enter info console command multiple times and see correct return value. mcdp info family:000e chipid:0001 irom:1.0.0 fw:0.0.0 Change-Id: Iaf2c088d5da1af7b2dab11abcfb6e32e289066ea Reviewed-on: https://chromium-review.googlesource.com/272692 Reviewed-by: Alec Berg <alecaberg@chromium.org> Commit-Queue: Todd Broch <tbroch@chromium.org> Tested-by: Todd Broch <tbroch@chromium.org>
* mcdp28x0: Add checksum verification to rx_serial.Todd Broch2015-05-222-13/+22
| | | | | | | | | | | | | | Signed-off-by: Todd Broch <tbroch@chromium.org> BRANCH=samus BUG=chrome-os-partner:35939 TEST=compiles, MCDP_READY gpio still asserted. Change-Id: If20a695380dc44d899951faeaa805bf7acfae1e1 Reviewed-on: https://chromium-review.googlesource.com/272691 Reviewed-by: Alec Berg <alecaberg@chromium.org> Commit-Queue: Todd Broch <tbroch@chromium.org> Tested-by: Todd Broch <tbroch@chromium.org>
* driver: Add BMM150 behind BMI160 support.Gwendal Grignou2015-05-163-38/+265
| | | | | | | | | | | | | | | | Add support for Bosh Sensortec BMM160 compass. We access it through BMI150. BRANCH=none BUG=chrome-os-partner:39900 TEST=Test on a nucleo board and smaug. Change-Id: I5b959cab4f9341ba0fcd3ed9bad815fa92f80a37 Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/271525 Reviewed-by: Sheng-liang Song <ssl@chromium.org> Reviewed-by: Vincent Palatin <vpalatin@chromium.org> Trybot-Ready: Vincent Palatin <vpalatin@chromium.org>
* driver: Add BMI160 basic driver supportGwendal Grignou2015-05-123-0/+647
| | | | | | | | | | | | | | Basic initialization of BMI160. Fit into the existing accel/gyro framework. BUG=chrome-os-partner:36018 BRANCH=none TEST=Ability to read samples with accelinfo. Change-Id: I5c86d4c3964eb6f876dd4042e5019195ffcca4ed Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/270454 Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* driver: Use common data structure to store default accel valuesGwendal Grignou2015-05-123-26/+19
| | | | | | | | | | | | | | | Move structure used by lms6ds0 to motion_sense.h, so that bosh driver can use the same mechanism. Use code to avoid reading chip range when reading data. BUG=none BRANCH=none TEST=Check Bosh driver is working as expected. Change-Id: Id8b5bb8735e479a122ef32ab9a400fba189d7488 Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/270453 Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* bq24770: Corrected charger driver used an incorrect SMBUS address.Kevin K Wong2015-04-292-14/+19
| | | | | | | | | | | | | | BUG=none TEST=Verified with a SMBus analyzer that only the expected device address is detected on the bus. BRANCH=none Change-Id: Ib8c8589544b9ec11127619a1120eb21f211fd690 Signed-off-by: Kevin K Wong <kevin.k.wong@intel.com> Reviewed-on: https://chromium-review.googlesource.com/267472 Reviewed-by: Alec Berg <alecaberg@chromium.org> Reviewed-by: Shawn N <shawnn@chromium.org> Commit-Queue: Divya Jyothi <divya.jyothi@intel.com>
* bq2589x: update driverstabilize-6996.BVincent Palatin2015-04-212-9/+51
| | | | | | | | | | | | | | | | | | | | | | | Update the BQ2589x charger driver to configure properly the boost used as a VBUS 5V source. Define the bits used for I2C registers configuration. Return success in unused charger callbacks to avoid blocking the charge state machine. Signed-off-by: Vincent Palatin <vpalatin@chromium.org> BRANCH=none BUG=chrome-os-partner:38603 TEST=On Ryu P4 reworked with BQ25892, plug a C-A receptacle adapter and see the 5V VBUS coming up, un-plug it and see VBUS going away, try several PD/type-C charger and check the selected current limit. Change-Id: I24b832b6d130ff6dfda1ce47f5e445d65279fa7d Reviewed-on: https://chromium-review.googlesource.com/266063 Trybot-Ready: Vincent Palatin <vpalatin@chromium.org> Tested-by: Vincent Palatin <vpalatin@chromium.org> Reviewed-by: Alec Berg <alecaberg@chromium.org> Commit-Queue: Vincent Palatin <vpalatin@chromium.org>
* lsm6ds0: Cache ODR and range on EC.Aseda Aboagye2015-04-202-20/+26
| | | | | | | | | | | | | | | | | | | | | | For the driver functions get_range and get_data_rate, each call would end up executing an i2c transaction even if the value had not changed. Therefore, I modified the lsm6ds0 driver to cache the output data rate as well as the range. This prevents unecessary i2c transactions from occuring. BUG=chromium:476226 TEST=Flashed EC on samus and verified that the accelrange and accelrate commands still worked and that the sensors were functional. TEST=Verified Double Tap still worked. TEST=make -j buildall tests BRANCH=none Change-Id: Ie432979266dc4e4892978005de5d1df62cc0654f Signed-off-by: Aseda Aboagye <aaboagye@google.com> Reviewed-on: https://chromium-review.googlesource.com/265933 Reviewed-by: Alec Berg <alecaberg@chromium.org> Commit-Queue: Aseda Aboagye <aaboagye@chromium.org> Tested-by: Aseda Aboagye <aaboagye@chromium.org>
* charger: add TI BQ2589x charger driverVincent Palatin2015-04-023-0/+362
| | | | | | | | | | | | | | | | | | Driver for Texas Instrument bq25890/bq25892/bq25895 battery charger chip. Signed-off-by: Vincent Palatin <vpalatin@chromium.org> BRANCH=none BUG=chrome-os-partner:38603 TEST=On a modified board with BQ25892, charge a 1S battery and check ADC values. Change-Id: I536c6b58438464a63ad3d3536b9bb84ff35920e8 Reviewed-on: https://chromium-review.googlesource.com/263458 Reviewed-by: Bill Richardson <wfrichar@chromium.org> Commit-Queue: Vincent Palatin <vpalatin@chromium.org> Tested-by: Vincent Palatin <vpalatin@chromium.org>
* Skip the battery device name reading on BQ27742Vincent Palatin2015-03-261-0/+6
| | | | | | | | | | | | | | | | | | | | Contrary to the BQ2751 and BQ27741 it is sharing code with, BQ27742 does not have a "device name" register. So we need to skip the I2C reads else the battery_device_name() function returns an I2C error and the charge code retries until the end-of-time to read it hogging the CPU. Signed-off-by: Vincent Palatin <vpalatin@chromium.org> BRANCH=none BUG=chrome-os-partner:38401 TEST=run on Ryu P4 and verify that we are no longer seeing 20ms of I2C transactions every 100ms on the battery I2C bus. Change-Id: I961af54017f661ee928058b346a42b7206ad8217 Reviewed-on: https://chromium-review.googlesource.com/262449 Reviewed-by: Alec Berg <alecaberg@chromium.org> Commit-Queue: Vincent Palatin <vpalatin@chromium.org> Tested-by: Vincent Palatin <vpalatin@chromium.org>
* charger: bq24773: Fix read input current errorstabilize-6912.Bjames_chao2015-03-241-2/+2
| | | | | | | | | | | | | | | | | | | 'ectool chargestate show' shows the wrong input current since the function charger_get_input_current() uses REG8_TO_CURRENT. BUG=None TEST=Use 'ectool chargestate show' or UART command 'charger' check the input current value. BRANCH=None Signed-off-by: james_chao <james_chao@asus.com> Change-Id: I29229ea1ef22811035b500c7a33fedee6562db35 Reviewed-on: https://chromium-review.googlesource.com/259842 Reviewed-by: Shawn N <shawnn@chromium.org> Reviewed-by: Divya Jyothi <divya.jyothi@intel.com> Reviewed-by: Randall Spangler <rspangler@chromium.org> Tested-by: Divya Jyothi <divya.jyothi@intel.com> Commit-Queue: Shawn N <shawnn@chromium.org>
* charger: Add support for bq24770james_chao2015-03-243-27/+108
| | | | | | | | | | | | | | | | Add support for bq24770 (smbus) in the bq24773 (i2c) driver. BUG=None TEST=Use the UART command "charger" and check the charger information. BRANCH=None Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org> Change-Id: Ie5f5af60e93aa73d9ef68115af36a8d28f6d6c2b Reviewed-on: https://chromium-review.googlesource.com/259870 Reviewed-by: BoChao Jhan <james_chao@asus.com> Reviewed-by: Divya Jyothi <divya.jyothi@intel.com> Commit-Queue: Divya Jyothi <divya.jyothi@intel.com> Tested-by: Divya Jyothi <divya.jyothi@intel.com>
* pi3usb9281: Always set reserved control bitsShawn Nematbakhsh2015-03-042-10/+14
| | | | | | | | | | | | | | | | Bits 1 and 3 of the control register are read 1, write 1, but RO firmware may have zero'd these bits. Therefore, always set the bits high, ignoring the read value. TEST=Manual on Samus. Starting from .90 RO, flash new RW and verify BC1.2 charger detection is working. BUG=chrome-os-partner:37241 BRANCH=Samus Change-Id: I2f71718f74e50fe9b664dbe3da1578ee4c995136 Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/254880 Reviewed-by: Alec Berg <alecaberg@chromium.org>
* Producer/Consumer: Convert USART and USB Stream driversAnton Staaf2015-03-021-8/+18
| | | | | | | | | | | | | | | | | | | | | | | Previously the USART and USB Stream drivers exposed in_stream and out_stream interfaces, which don't allow for sharing their queues easily. This change converts these drivers over to the producer/consumer model and updates the two uses. Signed-off-by: Anton Staaf <robotboy@chromium.org> BRANCH=None BUG=None TEST=make buildall -j Verify that the discovery echo functionality is unchanged. Change-Id: I29f043ab1712373f638e1621378df98647d736cf Reviewed-on: https://chromium-review.googlesource.com/252820 Trybot-Ready: Anton Staaf <robotboy@chromium.org> Tested-by: Anton Staaf <robotboy@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org> Reviewed-by: Todd Broch <tbroch@chromium.org> Tested-by: Todd Broch <tbroch@chromium.org> Commit-Queue: Anton Staaf <robotboy@chromium.org>
* pi3usb9281: Fix handling of REG_CONTROL (02H) reserved bitsShawn Nematbakhsh2015-02-052-15/+22
| | | | | | | | | | | | | | | | | REG_CONTROL has two sets of reserved bits: - Bits 5 thru 7 are read x, write 0. - Bits 1 and 3 have undocumented function and should not be changed from read value. BUG=chrome-os-partner:36360 TEST=Manual on Samus. Cold boot unit and insert 2.4A charger. Verify that charger is correctly detected. BRANCH=Samus Change-Id: I240d352817910eda404b72be13e2c913a4b76079 Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/246560 Reviewed-by: Alec Berg <alecaberg@chromium.org>
* samus: automatically recover from charge circuit failuresstabilize-6752.BAlec Berg2015-02-031-0/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Occasionally the charge circuit on samus gets wedged and will not charge. This change detects when the charge circuit has failed and automatically recovers from it. It uses the BQ PROCHOT warning to detect the failure by setting PROCHOT to trigger when the BQ thinks input current is higher than the input current limit. When the failure is detected, the EC disables charging and tells PD MCU to disable CHARGE_EN, then a couple seconds later, it re-enables charging. This CL also adds more communication between EC and PD for the EC to be able to set the charge state for the PD. Valid charge states are: No charging allowed, 5V charging only, and max charging. The EC uses this as such: - When the EC gets AC present interrupt, it sets off a deferred function to change charge state to max charging after some delay to give time for the charge circuit to settle down. - When the EC gets AC disconnect interrupt, it disables charging briefly, enables learn mode, and then sets 5V charging allowed. This allows for the same starting conditions in the charge circuit for every AC attach. - When the EC detects a wedged charge circuit, it disables charging and waits a few seconds before re-enabling 5V only charging. Additionally, this change moves the charging cutoff in S3/S5/G3 when the battery is full to the EC. With the added control for the EC to set the PD charging state, it is more convenient for the EC to manage cutting off charging when battery is full. BUG=chrome-os-partner:36081 BRANCH=samus TEST=test the basics: - connect/disconnect zinger a bunch of times - connect and disconnect two zingers in different order - connect two zingers and charge override between the two test the automatic charge wedge recover: - wedge the charge circuit by setting charger voltage under battery voltage: "charger voltage 7000" - wait a few seconds for the system to recover and check it is charging with "battery" command test full battery charge cutoff: - added console command to change battery soc in board/samus/extpower.c: static int cmd_battfake(int argc, char **argv) { char *e; battery_soc = strtoi(argv[1], &e, 10); batt_soc_change(); return EC_SUCCESS; } DECLARE_CONSOLE_COMMAND(battfake, cmd_battfake, "", "", NULL); - in S0, tested "battfake 100" does not disable charging. - in G3, tested "battfake 100" disables charging and "battfake 99" re-enables charging. - set "battfake 100" and tested transitioning to S0 enables charging and transitioning to S5 disables charging. - attached two chargers and used charge override to select active port. then toggled "battfake 100" to "battfake 99" back and forth and verified charge override port is still the same. test third-party 12V charger: - plug in a bunch of times and make sure we stay at 5V for 500ms and then transition to 12V test with no battery: - tested five different units with no battery and just zinger. 3/5 boot, while the other 2 don't. But, the 2 that don't boot without battery also can't boot w/o battery when this CL is reverted, so I don't think this change is causing the problem, I think there is an electrical limitation. test with EVT zinger: - EVT zingers (P2 - C2) negotiate very quickly after connection, which can cause INA problems w/o this CL. Tested an EVT zinger with samus and did a bunch of connections and disconnections and verified that we always wait at 5V for 500ms and that we don't wedge the INA circuit on connect. test backwards compatibility: - test new PD with old EC and make sure we can charge with zinger. (note that if the charge circuit wedges, we won't be able to unwedge it). - test old PD with new EC and make sure we can charge with zinger. Change-Id: I7703b7a2ab1209d7f559b265b03517e79c74b16a Signed-off-by: Alec Berg <alecaberg@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/245253 Reviewed-by: Duncan Laurie <dlaurie@chromium.org>
* mcdp28x0: Move structure definitions to ec_commands.hShawn Nematbakhsh2015-01-312-16/+1
| | | | | | | | | | | | | | mcdp_info is a logging payload, so related structures need to be moved to the public include file. BUG=chrome-os-partner:35935 TEST=make buildall -j BRANCH=Samus Change-Id: Idb939db884821fa85faafbfe643e713f5bcdbc59 Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/244780 Reviewed-by: Alec Berg <alecaberg@chromium.org>
* ryu: Implement charging profileVic Yang2015-01-292-0/+216
| | | | | | | | | | | | | | | This allows us to charge at a faster rate. BRANCH=Ryu BUG=None TEST=Charge Ryu P3 in S5 and check charging current. Change-Id: If8fbaa42d34df45f3d4db35ba50031c511b0c7af Signed-off-by: Vic Yang <victoryang@google.com> Reviewed-on: https://chromium-review.googlesource.com/242666 Tested-by: Vic Yang <victoryang@chromium.org> Reviewed-by: Alec Berg <alecaberg@chromium.org> Commit-Queue: Vic Yang <victoryang@chromium.org>
* ectool: parse accessory logs for dingdong & hohoTodd Broch2015-01-281-2/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Signed-off-by: Todd Broch <tbroch@chromium.org> BUG=chrome-os-partner:35935 TEST=manual # With dingdong in C0 & hoho in C1 # Enter GFU mode for dingdong & hoho ectool --name cros_pd pdsetmode 0 0x18d1 1 1 ectool --name cros_pd pdsetmode 1 0x18d1 1 1 # read logs ectool --name cros_pd pdlog 2015-01-26 14:36:54.787 P0 SRC 2015-01-26 14:36:54.780 P1 SRC 2015-01-26 14:36:53.680 P0 DP mode enabled 2015-01-26 14:36:53.375 P1 HDMI Codec: family:000e chipid:0001 irom:1.0.0 fw:0.0.0 2015-01-26 14:36:53.771 P1 DP mode enabled # remove hoho & plug in zinger instead ectool --name cros_pd pdlog 2015-01-26 14:44:36.991 P1 SNK Charger Type-C 5153mV max 5000mV / 3000mA 2015-01-26 14:44:37.011 P1 SNK Charger PD 5021mV max 20000mV / 3000mA 2015-01-26 14:44:37.116 P1 SNK Charger PD 20211mV max 20000mV / 3000mA Change-Id: I0289cfd1d43ef1a22123b437bc8df86920fbf1a7 Reviewed-on: https://chromium-review.googlesource.com/243375 Reviewed-by: Vincent Palatin <vpalatin@chromium.org> Reviewed-by: Alec Berg <alecaberg@chromium.org> Tested-by: Todd Broch <tbroch@chromium.org> Commit-Queue: Todd Broch <tbroch@chromium.org>
* bq24773: turn off prochot warningAlec Berg2015-01-262-3/+7
| | | | | | | | | | | | | | | | | | | | | | Turn off prochot warning on bq24773 by default because our battery can always supply enough power for the whole system so we don't need to throttle the CPU if the BQ senses too much input current. BUG=chrome-os-partner:34885 BRANCH=samus TEST=force BQ into it's prochot condition on samus by setting the charging voltage temporarily below the battery voltage, which causes INA to turn off and the BQ to think IADP is > 4.1A. in this condition PROCHOT is normally asserted and CPU slows down, but with this patch PROCHOT is not asserted and the CPU does not slow down. Change-Id: I658dbe568b7bfe94944ef90d6d59656a0683c8a0 Signed-off-by: Alec Berg <alecaberg@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/243231 Reviewed-by: Duncan Laurie <dlaurie@chromium.org> Reviewed-by: Sameer Nanda <snanda@chromium.org>
* samus: modify fast charging profile to avoid charge problemsAlec Berg2015-01-261-29/+91
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Several modifications to samus fast charging to fix bug where charging circuit stops charging the battery. - Fix bug: if we have a bad temperature reading, fast charging should ignore it. - Change the fast charging high temperature profile to set a charging voltage equal to the maximum of 8.3V and the current battery voltage. - Divide the normal temperature profile into two phases, low voltage charging and high voltage charging. Once we transition to second phase, don't allow it to go back to phase 1 unless AC is removed. On samus, we have to make sure we never command the BQ to a charging voltage that is below the present battery voltage or else the INA will lose power and we will not be able to charge the battery until AC is disconnected. This also changes charge_state_v2 so that the fast charging profile override is called even when AC is disconnected to avoid jumps in temperature as seen by the fast charging code. Also changes the voltage threshold for transitioning from phase 1 to phase 2 of normal temp charging so that the transition is taken a little earlier to match the desired profile slightly better. BUG=chrome-os-partner:35491 BRANCH=samus TEST=Added custom console command to be able to directly control the battery temperature that charger_profile_override() uses: static int command_chgtemp(int argc, char **argv) { char *e; if (argc < 2) return EC_ERROR_PARAM_COUNT; chg_temp = strtoi(argv[1], &e, 10); if (*e) return EC_ERROR_PARAM1; return EC_SUCCESS; } DECLARE_CONSOLE_COMMAND(chgtemp, command_chgtemp, "", "", NULL); Using this command, I jumped back and forth between all three temperature fast charging regions and made sure that (1) we never set a charging voltage below the present battery voltage and (2) we never stop charging the battery. I ran this test at low battery and high battery percentage and with low load (G3) and high load (S0 with webgl aquarium). Change-Id: I035603a4ab48a156ab43f8c93f21200c4b664aab Signed-off-by: Alec Berg <alecaberg@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/243143 Reviewed-by: Duncan Laurie <dlaurie@chromium.org>
* samus: add battery cutoffAlec Berg2015-01-241-0/+24
| | | | | | | | | | | | | | Add battery cutoff to samus. BUG=chrome-os-partner:35744 BRANCH=samus TEST=tested "cutoff" console command cuts off battery and "ectool batterycutoff" from host cuts off battery Change-Id: I88194c9c601594dee144933cabef5b1dc536ab0d Signed-off-by: Alec Berg <alecaberg@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/242830 Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* bq27541: report battery present stateVic Yang2015-01-241-2/+12
| | | | | | | | | | | | | | | | The battery driver is not reporting battery present state, and as a result, is_present flag always remain NOT_SURE. Fix it. BRANCH=Ryu BUG=None TEST=On Ryu, 'chgstate' and see 'is_present = YES'. Change-Id: I84bedc390158797bf1e67e612d0bb3f526292dfa Signed-off-by: Vic Yang <victoryang@google.com> Reviewed-on: https://chromium-review.googlesource.com/242970 Reviewed-by: Alec Berg <alecaberg@chromium.org> Commit-Queue: Vic Yang <victoryang@chromium.org> Tested-by: Vic Yang <victoryang@chromium.org>