diff options
author | Caveh Jalali <caveh@chromium.org> | 2021-05-21 19:39:46 -0700 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2021-05-27 00:49:23 +0000 |
commit | 2a85f58b5c17afc725784de5c9d86dcd3a1ba9d8 (patch) | |
tree | 4adb721f271a44d972f56f46ad51104d6e99f2ba /board/brya | |
parent | 964fa09df258c2c5e28b91db54dfb95e66fcf658 (diff) | |
download | chrome-ec-2a85f58b5c17afc725784de5c9d86dcd3a1ba9d8.tar.gz |
brya: Board ID 1: Handle BATT_PRES reassignment
We are transitioning GPIO definitions to be correct for board ID 2. In
order to support board ID 1 with the same EC image, some GPIOs need to
be reconfigured to their legacy settings at runtime when board ID 1 is
detected. For board ID 2, the battery presence detect GPIO has moved to
the previous keyboard backlight enable pin.
BRANCH=none
BUG=b:183452273
TEST=booted on brya board ID 1, check battery present status on
ID_1_EC_BATT_PRES_ODL.
Cq-Depend: chromium:2914207
Change-Id: Ibae2a5e1f43c83360535e0d60c2a343bf9ef2421
Signed-off-by: Caveh Jalali <caveh@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2916413
Diffstat (limited to 'board/brya')
-rw-r--r-- | board/brya/board.c | 26 | ||||
-rw-r--r-- | board/brya/gpio.inc | 7 |
2 files changed, 27 insertions, 6 deletions
diff --git a/board/brya/board.c b/board/brya/board.c index 93b75977e9..f974b992d0 100644 --- a/board/brya/board.c +++ b/board/brya/board.c @@ -103,8 +103,15 @@ int board_is_vbus_too_low(int port, enum chg_ramp_vbus_state ramp_state) enum battery_present battery_hw_present(void) { + enum gpio_signal batt_pres; + + if (get_board_id() == 1) + batt_pres = GPIO_ID_1_EC_BATT_PRES_ODL; + else + batt_pres = GPIO_EC_BATT_PRES_ODL; + /* The GPIO is low when the battery is physically present */ - return gpio_get_level(GPIO_EC_BATT_PRES_ODL) ? BP_NO : BP_YES; + return gpio_get_level(batt_pres) ? BP_NO : BP_YES; } /* @@ -122,11 +129,12 @@ static void set_board_id_1_gpios(void) DECLARE_HOOK(HOOK_INIT, set_board_id_1_gpios, HOOK_PRIO_FIRST); /* - * ALT function group MODULE_ADC are set in HOOK_PRIO_INIT_ADC. - * Reclaim these as GPIO as needed for board ID 1. + * Reclaim GPIO pins on board ID 1 that are used as ADC inputs on + * current boards. ALT function group MODULE_ADC pins are set in + * HOOK_PRIO_INIT_ADC and can be reclaimed right after the hook runs. */ -static void id_1_reclaim_adc(void) +static void board_id_1_reclaim_adc(void) { if (get_board_id() != 1) return; @@ -141,6 +149,12 @@ static void id_1_reclaim_adc(void) */ gpio_set_flags(GPIO_ID_1_USB_C0_C2_TCPC_RST_ODL, GPIO_ODR_HIGH); gpio_set_alternate_function(GPIO_PORT_3, BIT(4), GPIO_ALT_FUNC_NONE); -} -DECLARE_HOOK(HOOK_INIT, id_1_reclaim_adc, HOOK_PRIO_INIT_ADC + 1); + /* + * The pin gets set to ADC7 in HOOK_PRIO_INIT_ADC, so we simply + * need to set it back to GPIOE1. + */ + gpio_set_flags(GPIO_ID_1_EC_BATT_PRES_ODL, GPIO_INPUT); + gpio_set_alternate_function(GPIO_PORT_E, BIT(1), GPIO_ALT_FUNC_NONE); +} +DECLARE_HOOK(HOOK_INIT, board_id_1_reclaim_adc, HOOK_PRIO_INIT_ADC + 1); diff --git a/board/brya/gpio.inc b/board/brya/gpio.inc index e1619c1176..4b243979dd 100644 --- a/board/brya/gpio.inc +++ b/board/brya/gpio.inc @@ -29,6 +29,13 @@ GPIO(EC_KSO_02_INV, PIN(1, 7), GPIO_OUT_LOW) /* + * GPIOE1 is an ALT function ADC INPUT on board ID 2 and a GPIO INPUT on + * board ID 1. This declaration gives us a signal name to use on board + * ID 1. + */ +GPIO(ID_1_EC_BATT_PRES_ODL, PIN(E, 1), GPIO_INPUT) + +/* * GPIO34 is an INPUT on board ID 2 and ODR_LOW on board ID 1. * * Since this pin is pulled up to 3.3V through a 30.9K ohm resistor on |