summaryrefslogtreecommitdiff
path: root/chip/stm32/usb_power.c
Commit message (Collapse)AuthorAgeFilesLines
* i2c: Split i2c_xfer into locked/unlocked versions.Jonathan Brandmeyer2018-08-161-4/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Rename i2c_xfer to i2c_xfer_unlocked. Audit all users of i2c_xfer to see if they can use simple locking semantics or require their own locking. Since locked accesses are only safe for I2C_XFER_SINGLE transactions, remove the flags parameter from i2c_xfer. This also makes the audit a bit easier. Some remaining applications hold the bus locked across several transactions that would otherwise be atomic, and a few others implement complex I2C transactions in multiple commands. Add a (nondeterministic) verification on the I2C port locking correctness. This will catch all statically incorrect locking patterns, although dynamically incorrect locking patterns may not be caught. Related: Revise the i2c_port_active_count to be a bitmap of the active ports instead of a count of the active ports. The EC's mutex does not provide an is_locked() primitive, and we would prefer not to have one. - board/glados: Custom locking for battery reset - board/mchpevb1: Custom locking for battery reset - board/oak: Custom locking for battery reset - board/samus: Custom locking for lightbar reset - board/sweetberry: simple locking - board/servo_micro: Custom locking for funky i2c transfers - capsense: simple locking - host_command_master: multi-command transactions - lb_common: manual locking to support samus power sequence - smbus: multi-command transactions - usb_i2c: simple locking - driver/tcpm/fusb302: simple locking and multi-command transactions - driver/tcpm/tcpi: Forward _unlocked and implicitly locked interface to fusb302 - driver/touchpad_elan: simple locking BUG=chromium:871851 BRANCH=none TEST=buildall; very careful audit TEST=grunt clamshell and Coral clamshell, test boot, battery charging, PD communication, and TCPC port low-power mode. Signed-off-by: Jonathan Brandmeyer <jbrandmeyer@chromium.org> Change-Id: Ieabf22bcab42780bdb994fca3ced5d8c62519d56 Reviewed-on: https://chromium-review.googlesource.com/1169913 Commit-Ready: Jonathan Brandmeyer <jbrandmeyer@chromium.org> Tested-by: Jonathan Brandmeyer <jbrandmeyer@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org>
* i2c: add i2c_lock before and after calling i2c_xferZhuohao Lee2018-08-071-0/+3
| | | | | | | | | | | | | | | According to the include/i2c.h, we need to call i2c_lock before and after calling i2c_xfer. This patch adds the lock to protect the i2c data transmission. BUG=none BRANCH=master TEST=make buildall -j Change-Id: If125333902105c35ca332c154bbb8012c363d1bf Signed-off-by: Zhuohao Lee <zhuohao@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1163543 Reviewed-by: Nick Sanders <nsanders@chromium.org>
* sweetberry: add current and voltage loggingNick Sanders2018-03-281-19/+80
| | | | | | | | | | | | | | | | | | | | | This adds a config to specify whether sweetberry should measure power, current, voltage per powerlog entry. The json format is slightly revised to allow data type per channel. powerlog and sweetberry fw are updated to handle the new functionality. BUG=b:72973433 BRANCH=None TEST=./powerlog.py -b marlin.board -c marlin_a.scenario -s .5 Signed-off-by: Nick Sanders <nsanders@chromium.org> Change-Id: I231fc6600495146fad30583872bf14c660d5a50b Reviewed-on: https://chromium-review.googlesource.com/905427 Commit-Ready: Nick Sanders <nsanders@chromium.org> Tested-by: Nick Sanders <nsanders@chromium.org> Reviewed-by: Mengqi Guo <mqg@chromium.org>
* chip/stm32/usb: Replace reset handler by generic event handlerNicolas Boichat2017-08-161-1/+5
| | | | | | | | | | | | | | | | | | | Some USB interface handlers need to know when USB has been successfully resumed after a wake event. For example, this is useful so that HID keyboard can send the events at the right time. BRANCH=none BUG=b:35775048 TEST=Using USB HID keyboard patches to queue keys in a FIFO: After USB autosuspends, press a single key and hold it. Without this patch the endpoint data only gets reloaded on the _next_ event. TEST=On hammer, I2C passthrough still works. Change-Id: I9b52b9de16767c8a66c702a5ae70369334a3d590 Signed-off-by: Nicolas Boichat <drinkcat@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/569547 Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* sweetberry: allow larger sense resistorsNick Sanders2017-07-241-6/+11
| | | | | | | | | | | | | | | | | | Currently sweetberry hits an integer truncation issue at 2.4 ohm when uA per div goes below 1. We can use 100ths of a uA as the current per div scale. BRANCH=None BUG=chromium:608039 TEST=log from sweetberry with 10 ohm config. Signed-off-by: Nick Sanders <nsanders@chromium.org> Change-Id: I9e9216230329483fd0bfcb44ce23cd15bae864b3 Reviewed-on: https://chromium-review.googlesource.com/577051 Commit-Ready: Nick Sanders <nsanders@chromium.org> Tested-by: Nick Sanders <nsanders@chromium.org> Reviewed-by: Nick Sanders <nsanders@chromium.org>
* stm32: Remove useless code from usb_power.cMartin Roth2016-12-261-12/+0
| | | | | | | | | | | | | | | | | | | | | The function usb_power_map_error() is only called from a single location, with a fixed value passed in, and the return value, which is the only reason for the function, is ignored. The whole thing is useless, so remove the function and call. Since the sizes of all platforms are unchanged before and after removing this, I suspect it was getting optimized out anyway. Fixes coverity warning 157563: Useless call BUG=None BRANCH=None TEST=build tested only. Change-Id: Ie6572d2f5579819f06a53a567e1a93aabca217db Signed-off-by: Martin Roth <martinroth@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/418070 Reviewed-by: Shawn N <shawnn@chromium.org>
* sweetberry: add usb power logging interfaceNick Sanders2016-11-111-0/+655
This allows logging of power data over sweetberry BUG=chromium:608039 TEST=log power data BRANCH=None Change-Id: I6f642384cbf223959294c7bd99bca0f9206775b8 Signed-off-by: Nick Sanders <nsanders@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/385540 Reviewed-by: Todd Broch <tbroch@chromium.org>