summaryrefslogtreecommitdiff
path: root/common/ec_ec_comm_slave.c
Commit message (Collapse)AuthorAgeFilesLines
* common/ec_ec_comm_slave: initialize seqPatrick Georgi2018-08-011-1/+1
| | | | | | | | | | Change-Id: Ibf196528fa8e16ec9bcd51151d0397f38c302d08 Signed-off-by: Patrick Georgi <pgeorgi@google.com> Found-by: Coverity Scan #182319 Reviewed-on: https://chromium-review.googlesource.com/1158564 Commit-Ready: Patrick Georgi <pgeorgi@chromium.org> Tested-by: Patrick Georgi <pgeorgi@chromium.org> Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
* common/ec_ec_comm_master/slave: Add support for EC hibernateNicolas Boichat2018-03-281-2/+32
| | | | | | | | | | | | | | Allows the lid to hibernate the base. BRANCH=none BUG=b:71874971 TEST=With following change, lid hibernates the base when in S5, and no AC is connected. Change-Id: I8c8017d638442ba8b17c8117d0b1b31f3538925f Signed-off-by: Nicolas Boichat <drinkcat@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/981914 Reviewed-by: Randall Spangler <rspangler@chromium.org>
* charge_state_v2: Store battery information in new structuresNicolas Boichat2018-02-071-11/+4
| | | | | | | | | | | | | | | | | | | On dual battery systems, this allows to keep both batteries information in similar structures. This also means that battery information can only be fetched via host commands EC_CMD_BATTERY_GET_STATIC/DYNAMIC (next CL will make it possible to fetch the information via shared memory/ACPI). BRANCH=none BUG=b:65697620 TEST=Boot lux/wand, dual-battery algorithm works, AP can fetch both battery information via host commands. Change-Id: I3c087e8f378c5cef0006f6bfe58335228a880e5b Signed-off-by: Nicolas Boichat <drinkcat@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/888381 Reviewed-by: Randall Spangler <rspangler@chromium.org> Reviewed-by: Furquan Shaikh <furquan@chromium.org>
* charge_state_v2: Add charge_set_output_current_limit functionNicolas Boichat2018-01-041-3/+2
| | | | | | | | | | | | | | | | | | | | | | This function sets up and enables "OTG" mode on the charger chip (i.e. use the charger to provide power from the battery). It also records the output current in curr.output_current, to make sure that the charger loop is aware that current is provided externally. We also add a CONFIG_CHARGER_OTG to remove these functions on boards that do not require it. BRANCH=none BUG=b:65697962 TEST=On wand, when discharging, battery status is updated every 5 seconds (and not every 60 seconds). Change-Id: Ibf93933436f3eb24552a8e1eb9d97522fca2ce79 Signed-off-by: Nicolas Boichat <drinkcat@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/842743 Reviewed-by: Randall Spangler <rspangler@chromium.org>
* wand: Make sure battery is cut-off when criticalNicolas Boichat2018-01-041-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Modify chipset_in_state to always say that the chipset is off, when we do not actually have a chipset (like on hammer): that makes sure the battery can actually be cut off (else the EC would just wait forever for the chipset to turn off). Also, wake the charger state on "AC" change, that is, when charging_allowed changes state, to make sure the charging loop is executed after lux tries to charge it (else the charging loop would wait until timeout expires, and wand would ask the battery to be cut off again). BRANCH=none BUG=b:65697962 TEST=Deplete wand battery, reboot without providing external power to it. After 30 seconds, battery is cut off: [1.354683 Low battery: 2%, 6866mV] [1.354888 charge warn shutdown due to critical battery] [31.381410 Low battery: 2%, 6865mV] [31.381643 charge force battery cut-off due to critical level] TEST=Upon providing power to wand, charging loop is executed regularly, and battery is charging. Change-Id: I7154b25bd852b8422a0ae3b506675a297a948132 Signed-off-by: Nicolas Boichat <drinkcat@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/842742 Reviewed-by: Randall Spangler <rspangler@chromium.org>
* ec_ec_comm_slave: Define extpower_is_presentNicolas Boichat2017-12-211-0/+20
| | | | | | | | | | | | | | | | | | | On dual-battery slave, we use the charging allowed signal from master to indicate whether external power is present. In most cases, this actually matches the external power status of the master (slave battery charging when AC is connected, or discharging when slave battery still has enough capacity), with one exception: when we do master to slave battery charging (in this case the "external" power is the master). BRANCH=none BUG=b:65697962 TEST=Deplete wand battery to 5%, see that lux still provides power to it but the battery does not charge. Change-Id: I8bd9f52c386a0a9edfae3837ba33725b3101a008 Signed-off-by: Nicolas Boichat <drinkcat@chromium.org>
* ec_ec_comm_slave: EC-EC communication slave task and functionsNicolas Boichat2017-12-201-0/+280
This adds functions required for the slave in EC-EC communication, including the task that processes requests from the master. This also adds required CONFIG_EC_EC_COMM_SLAVE/MASTER/BATTERY config options. BRANCH=none BUG=b:65697962 TEST=Build wand and lux boards, flash it, EC-EC communication works. Change-Id: I772d9023a830f4fbc37316ca31e4da8240de7324 Signed-off-by: Nicolas Boichat <drinkcat@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/828180 Reviewed-by: Vincent Palatin <vpalatin@chromium.org>