summaryrefslogtreecommitdiff
path: root/board
diff options
context:
space:
mode:
authorVincent Palatin <vpalatin@chromium.org>2014-06-18 18:08:04 -0700
committerchrome-internal-fetch <chrome-internal-fetch@google.com>2014-07-28 17:12:35 +0000
commit47e74b8ca8649d13cbe27db6ae0cee4c50215fee (patch)
tree5318a4039a9cfaf6f31d627eeeff1a817c023906 /board
parent1faa6ee20273cba9e898e192fc71d0d8ea704b3b (diff)
downloadchrome-ec-47e74b8ca8649d13cbe27db6ae0cee4c50215fee.tar.gz
zinger: do not trigger OCP on transients
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>
Diffstat (limited to 'board')
-rw-r--r--board/zinger/usb_pd_policy.c27
1 files changed, 22 insertions, 5 deletions
diff --git a/board/zinger/usb_pd_policy.c b/board/zinger/usb_pd_policy.c
index 5123b7c5a0..fded37ab11 100644
--- a/board/zinger/usb_pd_policy.c
+++ b/board/zinger/usb_pd_policy.c
@@ -205,18 +205,35 @@ int pd_board_checks(void)
/* re-enable fast OCP */
adc_enable_watchdog(ADC_CH_A_SENSE, MAX_CURRENT_FAST, 0);
- if ((fault == FAULT_FAST_OCP) || (vbus_amp > MAX_CURRENT)) {
- debug_printf("OverCurrent : %d mA\n",
- vbus_amp * VDDA_MV / CURR_GAIN * 1000 / R_SENSE / ADC_SCALE);
+ if (fault == FAULT_FAST_OCP) {
+ debug_printf("Fast OverCurrent\n");
fault = FAULT_OCP;
/* reset over-current after 1 second */
fault_deadline.val = get_time().val + OCP_TIMEOUT;
return EC_ERROR_INVAL;
}
+ if (vbus_amp > MAX_CURRENT) {
+ /* 3 more samples to check whether this is just a transient */
+ int count;
+ for (count = 0; count < 3; count++)
+ if (adc_read_channel(ADC_CH_A_SENSE) < MAX_CURRENT)
+ break;
+ /* trigger the slow OCP iff all 4 samples are above the max */
+ if (count == 3) {
+ debug_printf("OverCurrent : %d mA\n",
+ vbus_amp * VDDA_MV / CURR_GAIN * 1000
+ / R_SENSE / ADC_SCALE);
+ fault = FAULT_OCP;
+ /* reset over-current after 1 second */
+ fault_deadline.val = get_time().val + OCP_TIMEOUT;
+ return EC_ERROR_INVAL;
+ }
+ }
if ((output_is_enabled() && (vbus_volt > voltages[volt_idx].ovp)) ||
(fault && (vbus_volt > voltages[volt_idx].ovp_rec))) {
- debug_printf("OverVoltage : %d mV\n",
- vbus_volt * VDDA_MV * VOLT_DIV / ADC_SCALE);
+ if (!fault)
+ debug_printf("OverVoltage : %d mV\n",
+ vbus_volt * VDDA_MV * VOLT_DIV / ADC_SCALE);
/* TODO(crosbug.com/p/28331) discharge */
fault = FAULT_OVP;
/* no timeout */