mirror of
https://github.com/Telecominfraproject/OpenCellular.git
synced 2025-12-28 02:35:28 +00:00
eve: Use ternary encoding for board version
The Eve board version will use Hi-Z to get 3 values out of each bit in the version. In order to support this read each strap and determine the ternary encoding. BUG=chrome-os-partner:58666 BRANCH=none TEST=ensure P0 reports 0 and P1 reports 1, test with an unused GPIO to ensure that a tristate pin will also be read properly. Change-Id: Ib1f569e2b06bed0995eb70f24c90533cbccb0fb8 Signed-off-by: Duncan Laurie <dlaurie@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/418978 Reviewed-by: Scott Collyer <scollyer@chromium.org>
This commit is contained in:
committed by
chrome-bot
parent
fffc34706d
commit
aff701c574
@@ -590,6 +590,50 @@ void board_hibernate(void)
|
||||
bd9995x_set_power_save_mode(BD9995X_PWR_SAVE_MAX);
|
||||
}
|
||||
|
||||
static int gpio_get_ternary(enum gpio_signal gpio)
|
||||
{
|
||||
int pd, pu;
|
||||
int flags = gpio_get_default_flags(gpio);
|
||||
|
||||
/* Read GPIO with internal pull-down */
|
||||
gpio_set_flags(gpio, GPIO_INPUT | GPIO_PULL_DOWN);
|
||||
pd = gpio_get_level(gpio);
|
||||
usleep(100);
|
||||
|
||||
/* Read GPIO with internal pull-up */
|
||||
gpio_set_flags(gpio, GPIO_INPUT | GPIO_PULL_UP);
|
||||
pu = gpio_get_level(gpio);
|
||||
usleep(100);
|
||||
|
||||
/* Reset GPIO flags */
|
||||
gpio_set_flags(gpio, flags);
|
||||
|
||||
/* Check PU and PD readings to determine tristate */
|
||||
return pu && !pd ? 2 : pd;
|
||||
}
|
||||
|
||||
int board_get_version(void)
|
||||
{
|
||||
static int ver;
|
||||
|
||||
if (!ver) {
|
||||
/*
|
||||
* Read the board EC ID on the tristate strappings
|
||||
* using ternary encoding: 0 = 0, 1 = 1, Hi-Z = 2
|
||||
*/
|
||||
uint8_t id0, id1, id2;
|
||||
|
||||
id0 = gpio_get_ternary(GPIO_BOARD_VERSION1);
|
||||
id1 = gpio_get_ternary(GPIO_BOARD_VERSION2);
|
||||
id2 = gpio_get_ternary(GPIO_BOARD_VERSION3);
|
||||
|
||||
ver = (id2 * 9) + (id1 * 3) + id0;
|
||||
CPRINTS("Board ID = %d", ver);
|
||||
}
|
||||
|
||||
return ver;
|
||||
}
|
||||
|
||||
/* Base Sensor mutex */
|
||||
static struct mutex g_base_mutex;
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
#define CONFIG_ADC
|
||||
#define CONFIG_BOARD_HAS_BEFORE_RSMRST
|
||||
#define CONFIG_BOARD_VERSION
|
||||
#define CONFIG_BOARD_SPECIFIC_VERSION
|
||||
#define CONFIG_BUTTON_COUNT 2
|
||||
#define CONFIG_CASE_CLOSED_DEBUG_EXTERNAL
|
||||
#define CONFIG_DPTF
|
||||
@@ -241,6 +242,7 @@ enum adc_channel {
|
||||
#define PD_MAX_VOLTAGE_MV 20000
|
||||
|
||||
/* Board specific handlers */
|
||||
int board_get_version(void);
|
||||
void board_reset_pd_mcu(void);
|
||||
void board_set_tcpc_power_mode(int port, int mode);
|
||||
void board_print_tcpc_fw_version(int port);
|
||||
|
||||
Reference in New Issue
Block a user