summaryrefslogtreecommitdiff
path: root/include/peripheral_charger.h
Commit message (Collapse)AuthorAgeFilesLines
* PCHG: Handle reset eventDaisuke Nojiri2021-03-091-0/+3
| | | | | | | | | | | | | | | | | | | | Currently, PCHG assumes PCHG chips are reset only on POR and ignores reset events. This can cause the state machine to be in an unexpected state when a reset happens asynchronously. This patch allows PCHG to handle chip reset events. It also makes the task explicitly reset PCHG chips at start-up so that everything will start in known & clean states. BUG=b:181745891,b:181036152,b:173235954 BRANCH=trogdor TEST=Verify PCHG behaves expectedly across cold reset, warm reset, suspend & resume. Repeat the test with and without stylus. Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> Change-Id: Ia3dd1fe7ebc8dd6f4ee8149a4c25918922143fc3 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2741282 Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* PCHG: Get SOC proactively when device is detectedDaisuke Nojiri2021-02-121-0/+2
| | | | | | | | | | | | | | | | | This patch makes PCHG send CHG_CTRL_CHARGING_INFO_CMD when a stylus is detected. This will allow the EC to report 'full' to the host even if charging doesn't start (because the stylus is already charged). BUG=b:179390065,b:173235954 BRANCH=trogdor TEST=CoachZ. Re-attach charged stylus and verify PCHG_STATE_FULL is reported. Change-Id: Id8578e2d3d21294fb08a21933f12ecee7f2bd062 Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2691729 Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* pchg: Notify host of full chargeDaisuke Nojiri2021-02-121-0/+2
| | | | | | | | | | | | | | | | | | | Currently, full charge status is implied by capacity = 100 and PCHG_STATE_DETECTED (i.e. state='not charging'). If the charger stops charging before 100% (for battery health control), this condition doesn't work. This patch makes PCHG send PCHG_STATE_FULL explicitly when it sees the soc goes above the threshold in PCHG_STATE_DETECTED. BUG=b:179390065,b:173235954 BRANCH=trogdor TEST=CoachZ. Charge till 96% and verify PCHG0/state becomes 'Full'. Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> Change-Id: I634f96992cdc7ef44b5e43544603cc5cc9b3a62d Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2691366 Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* PCHG: Add host commandDaisuke Nojiri2020-12-101-13/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch adds a host command to get the peripheral charge port count and status. $ ectool pchg 1 $ ectool pchg 0 State: CHARGING (4) Battery: 50% Flags: 0x0 $ ectool pchg 0 foo Invalid parameter count Usage1: pchg Usage2: pchg <port> Usage1 prints the number of ports. Usage2 prints the status of a port. $ ectool pchg 100 Bad port index BUG=b:173235954 BRANCH=Trogdor TEST=Done on CoachZ. See the description above. Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> Change-Id: I33f261e48b16d5933b6f3ca9f3c12fec476edda3 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2555628 Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* PCHG: Add peripheral charge managerDaisuke Nojiri2020-11-241-0/+184
Peripheral charge manager communicates with peripheral charge chips to charge batteries of peripheral devices. Tested using Coachz proto and a listener evaluation board from NXP demo kit as follows: 1. Attach device then battery percentage is reported periodically. 2. Detach device then re-attach device to stop and resume charging. 3. Disable port by 'pchg 0 disable' to stop charging. 4. Enable disabled port by 'pchg 0 enable' to resume charging while device is in proximity. 5. When port is disabled, a device isn't detected or charged. BUG=b:173235954 BRANCH=Trogdor TEST=See the description above. Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> Change-Id: I0c2b583e5f7736b26ec7d1fb9cd9b6c59c7e8177 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2538536 Reviewed-by: Vincent Palatin <vpalatin@chromium.org>