diff options
author | Alec Berg <alecaberg@chromium.org> | 2015-01-15 12:28:11 -0800 |
---|---|---|
committer | ChromeOS Commit Bot <chromeos-commit-bot@chromium.org> | 2015-01-16 18:12:09 +0000 |
commit | 3cb209aa8e9b2d7a2320dc5657d76b6636d82dd3 (patch) | |
tree | 844d2b76237c8af77990a65c288b860337e8e6c7 | |
parent | 93bb7195a8d85ff0b7078b794d24ebab2e6828ff (diff) | |
download | chrome-ec-3cb209aa8e9b2d7a2320dc5657d76b6636d82dd3.tar.gz |
samus: add backboost detect interrupt and console command
Add backboost detect interrupt to latch if we ever start
backboosting. Provide console command "bkboost" to read if
this has ever happened.
BUG=none
BRANCH=samus
TEST=load on samus and test console command. Note: have not
tested that gpio actually goes high when backboosting
Change-Id: Id7520a0a7777925af1611b8cdc295203d5b36187
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/241031
Reviewed-by: Randall Spangler <rspangler@chromium.org>
-rw-r--r-- | board/samus/board.c | 12 | ||||
-rw-r--r-- | board/samus/board.h | 5 | ||||
-rw-r--r-- | board/samus/extpower.c | 24 | ||||
-rw-r--r-- | board/samus/gpio.inc | 2 |
4 files changed, 28 insertions, 15 deletions
diff --git a/board/samus/board.c b/board/samus/board.c index 3d28bfe20b..a3d68c6a5b 100644 --- a/board/samus/board.c +++ b/board/samus/board.c @@ -75,18 +75,6 @@ const struct adc_t adc_channels[] = { */ {"ECTemp", LM4_ADC_SEQ0, -225, ADC_READ_MAX, 420, LM4_AIN_NONE, 0x0e /* TS0 | IE0 | END0 */, 0, 0}, - - /* - * The charger current is measured with a 0.005-ohm - * resistor. IBAT is 20X the voltage across that resistor when - * charging, and either 8X or 16X (default) when discharging, if it's - * even enabled (default is not). Nothing looks at this except the - * console command, so let's just leave it at unity gain. The ADC - * returns 0x000-0xFFF for 0.0-3.3V. You do the math. - */ - {"ChargerCurrent", LM4_ADC_SEQ1, 1, 1, 0, - LM4_AIN(11), 0x06 /* IE0 | END0 */, LM4_GPIO_B, (1<<5)}, - /* * TODO(crosbug.com/p/23827): We don't know what to expect here, but * it's an analog input that's pulled high. We're using it as a battery diff --git a/board/samus/board.h b/board/samus/board.h index 876166e4b4..cd17381767 100644 --- a/board/samus/board.h +++ b/board/samus/board.h @@ -117,8 +117,6 @@ enum x86_signal { enum adc_channel { /* EC internal die temperature in degrees K. */ ADC_CH_EC_TEMP = 0, - /* Charger current in mA. */ - ADC_CH_CHARGER_CURRENT, /* BAT_TEMP */ ADC_CH_BAT_TEMP, @@ -176,6 +174,9 @@ enum als_id { /* Discharge battery when on AC power for factory test. */ int board_discharge_on_ac(int enable); +/* Backboost detected interrupt */ +void bkboost_det_interrupt(enum gpio_signal signal); + /* Bit masks for turning on PP5000 rail in G3 */ #define PP5000_IN_G3_AC (1 << 0) #define PP5000_IN_G3_LIGHTBAR (1 << 1) diff --git a/board/samus/extpower.c b/board/samus/extpower.c index 8a9a9b4010..0ad0ef0e2e 100644 --- a/board/samus/extpower.c +++ b/board/samus/extpower.c @@ -11,11 +11,16 @@ #include "charger.h" #include "chipset.h" #include "common.h" +#include "console.h" #include "extpower.h" #include "gpio.h" #include "hooks.h" #include "host_command.h" #include "task.h" +#include "util.h" + +/* Backboost has been detected */ +static int bkboost_detected; int extpower_is_present(void) { @@ -92,6 +97,9 @@ void extpower_task(void) int extpower = extpower_is_present(); extpower_board_hacks(extpower); + /* Enable backboost detection interrupt */ + gpio_enable_interrupt(GPIO_BKBOOST_DET); + while (1) { /* Wait until next extpower interrupt */ task_wait_event(-1); @@ -110,3 +118,19 @@ void extpower_task(void) host_set_single_event(EC_HOST_EVENT_AC_DISCONNECTED); } } + +void bkboost_det_interrupt(enum gpio_signal signal) +{ + /* Backboost has been detected, save it, and disable interrupt */ + bkboost_detected = 1; + gpio_disable_interrupt(GPIO_BKBOOST_DET); +} + +static int command_backboost_det(int argc, char **argv) +{ + ccprintf("Backboost detected: %d\n", bkboost_detected); + return EC_SUCCESS; +} +DECLARE_CONSOLE_COMMAND(bkboost, command_backboost_det, NULL, + "Read backboost detection", + NULL); diff --git a/board/samus/gpio.inc b/board/samus/gpio.inc index aa03281cf8..2f20e50fd8 100644 --- a/board/samus/gpio.inc +++ b/board/samus/gpio.inc @@ -22,6 +22,7 @@ GPIO(WP_L, A, 4, GPIO_INT_BOTH, switch_interrupt GPIO(PCH_BL_EN, M, 3, GPIO_INT_RISING, backlight_interrupt) /* PCH backlight input */ GPIO(JTAG_TCK, C, 0, GPIO_DEFAULT, jtag_interrupt) /* JTAG clock input */ GPIO(UART0_RX, A, 0, GPIO_PULL_UP | GPIO_INT_BOTH_DSLEEP, uart_deepsleep_interrupt) /* UART0 RX input */ +GPIO(BKBOOST_DET, B, 5, GPIO_INT_RISING, bkboost_det_interrupt) /* Backboost detect */ /* * Combined accelerometer input. This will become an interrupt, once we have @@ -47,7 +48,6 @@ GPIO(USB2_OC_L, E, 0, GPIO_INPUT, NULL) /* USB port overcurrent warning */ GPIO(USB2_STATUS_L, D, 7, GPIO_INPUT, NULL) /* USB charger port 2 status output */ GPIO(PD_IN_RW, A, 5, GPIO_INPUT, NULL) /* PD is in RW */ GPIO(PCH_HDA_SDO_L, G, 1, GPIO_INPUT, NULL) /* HDA_SDO signal to PCH to disable ME */ -GPIO(BKBOOST_DET, B, 5, GPIO_INPUT, NULL) /* Backboost detect */ /* Outputs; all unasserted by default except for reset signals */ GPIO(CPU_PROCHOT, B, 1, GPIO_OUT_LOW, NULL) /* Force CPU to think it's overheated */ |