summaryrefslogtreecommitdiff
path: root/board/zinger/usb_pd_policy.c
Commit message (Collapse)AuthorAgeFilesLines
...
* zinger: change source capabilities to support 20V at 3AAlec Berg2014-08-061-1/+1
| | | | | | | | | | | | | Changed source capabilities table to support 20V at 3A. BUG=none BRANCH=none TEST=make -j buildall Change-Id: I9dac730fff7e148a2667da12fd23c35036191dfd Signed-off-by: Alec Berg <alecaberg@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/211022 Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* samus_pd: remove dead code around allowing PD negotiationAlec Berg2014-08-061-5/+0
| | | | | | | | | | | | | | | | | | | | Remove code for preventing PD negotiation until the battery is at some minimum SOC. This was originally necessary because transitioning voltages would cause the source voltage to go briefly to 0V, which would kill power to the system unless the battery was at some minimum level of charge. But, that isn't true anymore. It is safe to transition up or down in voltage and the source voltage should never drop to 0V. BUG=chrome-os-partner:29499 BRANCH=none TEST=make -j buildall. No need to do any more testing because this code has been disabled for a while. Change-Id: I8a3dca117f01f0f9c7d04b5d489e4a8588a89be6 Signed-off-by: Alec Berg <alecaberg@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/211021 Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* zinger: fix down voltage transitions to keep output enabledAlec Berg2014-07-291-6/+29
| | | | | | | | | | | | | | | | | | | Fix bug in which output was disabled on down voltage transitions. This also changes the behavior of the OVP protection. On down-step transitions, the OVP threshold is not lowered for a specified amount of time after the transition to allow the output to dissipate down to the new voltage. This will still catch a problem if the voltage goes up instead of down, but avoid OVPing immediately on a normal down transition. BUG=chrome-os-partner:30389 BRANCH=none TEST=Attach to firefly and probe output voltage. Make sure we transition smoothly going down in voltage. Change-Id: I7f3a0c17cc8b392a25d24d56d2b7155b806acb64 Signed-off-by: Alec Berg <alecaberg@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/209863
* zinger: do not trigger OCP on transientsVincent Palatin2014-07-281-5/+22
| | | | | | | | | | | | | | | | | | | Ensure that the slow OCP (thermal/power protection) is not triggering for power spikes below 20us, by sampling 4 times (with a 5us sampling period). Signed-off-by: Vincent Palatin <vpalatin@chromium.org> BRANCH=none BUG=chrome-os-partner:28331 TEST=connect Zinger to Firefly+electronic load, test with various current pulse widths and amplitudes. Change-Id: Ic8150dbbf191c002bba9e8d3f70beb47af4577b9 Reviewed-on: https://chromium-review.googlesource.com/204588 Reviewed-by: Alec Berg <alecaberg@chromium.org> Tested-by: Alec Berg <alecaberg@chromium.org> Commit-Queue: Alec Berg <alecaberg@chromium.org>
* samus: pd: dual USB-PD port support for samusAlec Berg2014-07-281-5/+5
| | | | | | | | | | | | | | | | | | | | | | | | | Adds dual USB-PD port support for samus. Both ports are in dual-role and can perform either role. Both ports work fine when only one of the ports is in use. But, still having problems with PD errors on the lower priority port (port 0). If you have a charger plugged into port 0, and a type-C USB dongle plugged into port 1, then port 1 has higher priority, and in the SRC_DISCONNECTED state, every 1.5 seconds when it sends source cap packet, we occasionally drop pings on port 0, which results in a lot of start/stop charging. BUG=chrome-os-partner:28585 BRANCH=none TEST=Tested on samus to make sure both ports work when I plug in a charger and a type-C USB dongle with a pull-down on the CC line. Tested on plankton and zinger to make sure PD works as expected. Change-Id: Ie7bde3e258f5cd23a0b82b626c0993a45b0df074 Signed-off-by: Alec Berg <alecaberg@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/200750 Reviewed-by: Vic Yang <victoryang@chromium.org> Tested-by: Vic Yang <victoryang@chromium.org>
* zinger: update OVP latch conditionVincent Palatin2014-07-031-5/+9
| | | | | | | | | | | | | | | | | | | | | | | | | The Over Voltage Protection was de-activated when the output is disabled to avoid false positive when doing a down voltage transition, but as a side effect, we might reset the OVP while the fault is still present since the OVP first disables the output. So, we want to keep testing the OVP fault condition if there is a pre-existing fault. Also add a hysteris and ensure we recover from OVP only when we go under the new threshold. Signed-off-by: Vincent Palatin <vpalatin@chromium.org> BRANCH=none BUG=chrome-os-partner:28331 TEST=trigger an OVP using a voltage source and see the output is not re-enabled until we shutdown the voltage source. Change-Id: Idef3f630c3cfeb301e62f1e75c2a424b56bc98dd Reviewed-on: https://chromium-review.googlesource.com/206185 Reviewed-by: Alec Berg <alecaberg@chromium.org> Tested-by: Vincent Palatin <vpalatin@chromium.org> Commit-Queue: Vincent Palatin <vpalatin@chromium.org>
* zinger: tune over-current protectionVincent Palatin2014-06-261-2/+4
| | | | | | | | | | | | | | | | | | | | | | | | As per the new spec, use the fast OCP to protect against the short-circuits by putting the threshold at 4.5A. Set the slow OCP (a few dozen milliseconds latency) at 3.6A to limit the accepted current range. Also sample the current/voltage over a larger period (5us) to limit noise issues. Signed-off-by: Vincent Palatin <vpalatin@chromium.org> BRANCH=none BUG=chrome-os-partner:28331 TEST=plug Zinger on an electronic load and trigger the OCP with various pulses. Change-Id: Ia66cd186716aebf88646cbf5fd340388f8cdd48d Reviewed-on: https://chromium-review.googlesource.com/204590 Tested-by: Vincent Palatin <vpalatin@chromium.org> Reviewed-by: Todd Broch <tbroch@chromium.org> Reviewed-by: Alec Berg <alecaberg@chromium.org> Commit-Queue: Vincent Palatin <vpalatin@chromium.org>
* zinger: update current and voltage sensing gainsVincent Palatin2014-06-201-3/+3
| | | | | | | | | | | | | | | | | | | | | | | On the P2 boards, the operational amplifier gain for current sensing is exactly x100 rather than x101. (non-inverter configuration with R1=1.8kOhm R2=178kOhm) The voltage gain constant had a typo introducing a 10% error. the voltage divider is 10k/100k,so it's x11 gain. ie it should be written (10+100)/10 rather than (10+110). Signed-off-by: Vincent Palatin <vpalatin@chromium.org> BRANCH=none BUG=chrome-os-partner:28331 TEST=make BOARD=zinger checked manually with a voltmeter and traces. Change-Id: I8097ab50149fee319efc11ebae75802e8a49a7f8 Reviewed-on: https://chromium-review.googlesource.com/204540 Reviewed-by: Alec Berg <alecaberg@chromium.org> Commit-Queue: Vincent Palatin <vpalatin@chromium.org> Tested-by: Vincent Palatin <vpalatin@chromium.org>
* IRQ list support for enabling specific IRQs without common runtimeVic Yang2014-06-191-3/+3
| | | | | | | | | | | | | | | | | | | This adds back DECLARE_IRQ() support when building without common runtime. With this, we can enable only a subset of IRQs and avoid linking in other unused IRQ handlers. Note that after this change, all boards without common runtime need to have a ec.irqlist file. BUG=None TEST=Build Keyborg and check it still works. TEST=make buildall BRANCH=None Change-Id: If68062a803b9a78f383027a1625cf99eb3370d3f Signed-off-by: Vic Yang <victoryang@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/203264 Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* zinger: do not cut output on up voltage transitionsVincent Palatin2014-06-111-1/+2
| | | | | | | | | | | | | | | | | | | Update according to the current PD standard, a monotonic transition seems mandatory in all cases, so keep the voltage output enabled when increasing the output voltage. Signed-off-by: Vincent Palatin <vpalatin@chromium.org> BRANCH=none BUG=chrome-os-partner:28331 TEST=connect Zinger to Fruitpie and probe the VBUS voltage during a transition. Change-Id: I3c728cc0049ca41536efd4f075139626b7d371da Reviewed-on: https://chromium-review.googlesource.com/202657 Reviewed-by: Alec Berg <alecaberg@chromium.org> Commit-Queue: Vincent Palatin <vpalatin@chromium.org> Tested-by: Vincent Palatin <vpalatin@chromium.org>
* samus: Allow samus to charge w/o battery or with dead batterystabilize-5942.BAlec Berg2014-06-091-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Use a EC to PD host command to notify the PD MCU when a battery is present and charged enough that it is ok to negotiate for a higher power. The PD MCU will not negotiate until the host command is received, which allows the system to be powered without a battery or with a dead battery with 5V. BUG=chrome-os-partner:28611 BRANCH=none TEST=Tested on a samus: 1) Tested the normal case of battery charged and plugged in. When charger is plugged in, the device immediately starts negotiating for 20V and starts charging. 2) Tested with no battery. Plug in a charger, samus boots and stays alive. VBUS measured at 5V. When a battery is plugged in, device negotiates for 20V and starts charging. 3) Tested dead battery by taking a battery with no charge, and plugging in zinger. Everything boots, but PD does not negotiate for power. Then when battery reaches 1%, PD negotiates and zinger switches to 20V without causing a reboot. Change-Id: Iaa451403674e86cddbd3fe80e9503584910be576 Signed-off-by: Alec Berg <alecaberg@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/201958 Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* zinger: activate the watchdog.Vincent Palatin2014-05-271-0/+3
| | | | | | | | | | | | | | | | | | | | | Ensure we are never stuck somewhere without doing the safety checks by enabling the watchdog and reloading it in the safaty checks function. I have kept the default timing constants, so on STM32F0xx the watchdog period should be between 1.2s (LSI at 30kHz) and 2.0s (LSI at 50kHz). Signed-off-by: Vincent Palatin <vpalatin@chromium.org> BRANCH=none BUG=none TEST=add a 2s loop in the serial port interrupt handler and see the power supply rebooting. Change-Id: I000f2a36a31e1166adf63a36c2b7f52999adc928 Reviewed-on: https://chromium-review.googlesource.com/201575 Reviewed-by: Alec Berg <alecaberg@chromium.org> Commit-Queue: Vincent Palatin <vpalatin@chromium.org> Tested-by: Vincent Palatin <vpalatin@chromium.org>
* zinger: ensure we re-enable the output once a fault is clearedVincent Palatin2014-05-211-0/+5
| | | | | | | | | | | | | | | | | | When a fault is cleared, reset the PD state and communicate, so that we re-enable the output and negociate a new voltage. Signed-off-by: Vincent Palatin <vpalatin@chromium.org> BRANCH=none BUG=none TEST=on Zinger connected to Firefly, trigger an OCP (using an electronic load) and see that the output is re-enabled once the OCP is cleared after 1 second. Change-Id: I3199d2c8675ab43958321378fd7f65ac383468cc Reviewed-on: https://chromium-review.googlesource.com/200338 Commit-Queue: Vincent Palatin <vpalatin@chromium.org> Tested-by: Vincent Palatin <vpalatin@chromium.org> Reviewed-by: Alec Berg <alecaberg@chromium.org>
* zinger: fast over-current protectionVincent Palatin2014-05-171-1/+28
| | | | | | | | | | | | | | | | | | When the supply output is enabled, ensure that we detect quickly any over-current situation by setting an analog watchdog in continuous conversion mode. Signed-off-by: Vincent Palatin <vpalatin@chromium.org> BRANCH=none BUG=chrome-os-partner:28331 TEST=plug an electronic load to Zinger and see the OCP triggered quickly when we go above the current threshold. Change-Id: I7da50ef242addbd2f4f48f624494daa321ac22b2 Reviewed-on: https://chromium-review.googlesource.com/199924 Tested-by: Vincent Palatin <vpalatin@chromium.org> Reviewed-by: Alec Berg <alecaberg@chromium.org>
* zinger: add support to flash RW firmwareVincent Palatin2014-05-171-0/+58
| | | | | | | | | | | | | | | | | | | | | | | Allow flashing the RW firmware by sending Vendor-Defined Messages over the USB-PD link. This is not the secure update whose design is still under discussion, it's a simple update with integrity check. Signed-off-by: Vincent Palatin <vpalatin@chromium.org> BRANCH=none BUG=chrome-os-partner:28330 TEST=using the following CLs, ./util/flash_pd.py ./build/zinger/ec.RW.flat and see Zinger booting on RW, repeat the operations with different builds of the RW firmware. Change-Id: Icd90eb92f7321ccd66341a50b9dabd73c59c68c1 Reviewed-on: https://chromium-review.googlesource.com/197948 Reviewed-by: Alec Berg <alecaberg@chromium.org> Tested-by: Vincent Palatin <vpalatin@chromium.org> Commit-Queue: Vincent Palatin <vpalatin@chromium.org>
* zinger: increase OCP thresholdVincent Palatin2014-05-141-2/+2
| | | | | | | | | | | | | | | | | | As per hardware team request, use a higher over-current limit to avoid false positives due to measurement precision margin. Signed-off-by: Vincent Palatin <vpalatin@chromium.org> BRANCH=none BUG=chrome-os-partner:28331 TEST=use a Zinger connected to an electronic load and trigger the protection. Change-Id: If031f6f58b9b7119c6fa3fa3273c08f16cbbbebb Reviewed-on: https://chromium-review.googlesource.com/199552 Reviewed-by: Alec Berg <alecaberg@chromium.org> Commit-Queue: Vincent Palatin <vpalatin@chromium.org> Tested-by: Vincent Palatin <vpalatin@chromium.org>
* zinger: invert output controlVincent Palatin2014-05-071-6/+6
| | | | | | | | | | | | | | | | | | | | The electrical design has changed : the output enable GPIO (PF0) has switched from being the LM5050 shutdown pin to controlling directly the FET enabling. We need to invert the control logic and use it in push-pull mode rather than open-drain. Signed-off-by: Vincent Palatin <vpalatin@chromium.org> BRANCH=none BUG=chrome-os-partner:28332 TEST=plug a reworked Zinger to a firefly and check the firefly LED is displaying a solid ON (meaning the voltage is right). Change-Id: Iee79b07f49eade1fee7cac1986bc38ba21e04b25 Reviewed-on: https://chromium-review.googlesource.com/198240 Reviewed-by: Alec Berg <alecaberg@chromium.org> Commit-Queue: Vincent Palatin <vpalatin@chromium.org> Tested-by: Vincent Palatin <vpalatin@chromium.org>
* zinger: implement fault protectionVincent Palatin2014-05-051-7/+102
| | | | | | | | | | | | | | | | | | | | | | Detect over-current and over-voltage and trigger a fault. The over-current threshold is 10% over 3A (3.3A). Only currently implement the slow protection, the fast interrupt-based one will be done later. Signed-off-by: Vincent Palatin <vpalatin@chromium.org> BRANCH=none BUG=chrome-os-partner:28331 TEST=with Zinger connected to an electronic load, adjust the current to 3.35A and see the output voltage cut. Change-Id: I0e848192392fd73f0839d4bcb806528b2a6b9122 Reviewed-on: https://chromium-review.googlesource.com/197947 Commit-Queue: Vincent Palatin <vpalatin@chromium.org> Tested-by: Vincent Palatin <vpalatin@chromium.org> Reviewed-by: Alec Berg <alecaberg@chromium.org>
* pd: update policy, timeout and board callbacksVincent Palatin2014-04-301-0/+4
| | | | | | | | | | | | | | | | | | | | | | | Slightly modify interfaces for better sink-only devices implementation (eg Firefly) update the host mode management and the voltage selection and add a hook for board checks. Simplify the reception timeout and fix other timeout detections. Signed-off-by: Vincent Palatin <vpalatin@chromium.org> BRANCH=none BUG=none TEST=make buildall and use with the follow-up firefly board configuration CL. Change-Id: I0240295764c8605793dc80a2fc21357af1740744 Reviewed-on: https://chromium-review.googlesource.com/195585 Reviewed-by: Vincent Palatin <vpalatin@chromium.org> Tested-by: Vincent Palatin <vpalatin@chromium.org> Commit-Queue: Vincent Palatin <vpalatin@chromium.org>
* Zinger board configurationVincent Palatin2014-04-121-0/+108
Add the USB Power delivery PHY configuration, and all the pins and details to use the real Zinger board. Signed-off-by: Vincent Palatin <vpalatin@chromium.org> BRANCH=none BUG=none TEST=none Change-Id: Ic2d3616c9fd2bf3ebeccba74a5519697e7c3e899 Reviewed-on: https://chromium-review.googlesource.com/194220 Tested-by: Vincent Palatin <vpalatin@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org> Commit-Queue: Vincent Palatin <vpalatin@chromium.org>