diff options
author | Diana Z <dzigterman@chromium.org> | 2021-06-10 14:09:13 -0600 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2021-06-16 19:52:32 +0000 |
commit | 7a9b88e75a9e6e99643b0c45206d78f3c7f36ee9 (patch) | |
tree | 5e8d71f0b014f1b9a7e88df9b48027d1007dab8d | |
parent | ffa3298c8360adb169e4427b004d6c883bd57ad4 (diff) | |
download | chrome-ec-7a9b88e75a9e6e99643b0c45206d78f3c7f36ee9.tar.gz |
NCT38xx: Export boot type information
Outside code may need an understanding of our board's boot type, so
allow it to be exported from the driver.
BRANCH=None
BUG=b:183660105
TEST=make -j buildall
Signed-off-by: Diana Z <dzigterman@chromium.org>
Change-Id: Iec61872be283f9ef65ccf71e99d89cee7184f2f8
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2953874
Reviewed-by: Rob Barnes <robbarnes@google.com>
Commit-Queue: Rob Barnes <robbarnes@google.com>
-rw-r--r-- | driver/tcpm/nct38xx.c | 21 | ||||
-rw-r--r-- | driver/tcpm/nct38xx.h | 21 |
2 files changed, 31 insertions, 11 deletions
diff --git a/driver/tcpm/nct38xx.c b/driver/tcpm/nct38xx.c index f5527af3a5..1b620b5c40 100644 --- a/driver/tcpm/nct38xx.c +++ b/driver/tcpm/nct38xx.c @@ -22,14 +22,13 @@ #define CPRINTF(format, args...) cprintf(CC_USBPD, format, ## args) #define CPRINTS(format, args...) cprints(CC_USBPD, format, ## args) -enum nct38xx_boot_type { - BOOT_UNKNOWN, - BOOT_DEAD_BATTERY, - BOOT_NORMAL, -}; - static enum nct38xx_boot_type boot_type[CONFIG_USB_PD_PORT_MAX_COUNT]; +enum nct38xx_boot_type nct38xx_get_boot_type(int port) +{ + return boot_type[port]; +} + static int nct38xx_init(int port) { int rv; @@ -39,13 +38,13 @@ static int nct38xx_init(int port) * Detect dead battery boot by the default role control value of 0x0A * once per EC run */ - if (boot_type[port] == BOOT_UNKNOWN) { + if (boot_type[port] == NCT38XX_BOOT_UNKNOWN) { RETURN_ERROR(tcpc_read(port, TCPC_REG_ROLE_CTRL, ®)); - if (reg == 0x0A) - boot_type[port] = BOOT_DEAD_BATTERY; + if (reg == NCT38XX_ROLE_CTRL_DEAD_BATTERY) + boot_type[port] = NCT38XX_BOOT_DEAD_BATTERY; else - boot_type[port] = BOOT_NORMAL; + boot_type[port] = NCT38XX_BOOT_NORMAL; } RETURN_ERROR(tcpc_read(port, TCPC_REG_POWER_STATUS, ®)); @@ -57,7 +56,7 @@ static int nct38xx_init(int port) * be delayed if we have booted from a dead battery with a debug * accessory and change this bit (see b/186799392). */ - if ((boot_type[port] == BOOT_DEAD_BATTERY) && + if ((boot_type[port] == NCT38XX_BOOT_DEAD_BATTERY) && (reg & TCPC_REG_POWER_STATUS_DEBUG_ACC_CON)) CPRINTS("C%d: Booted in dead battery mode, not changing debug" " control", port); diff --git a/driver/tcpm/nct38xx.h b/driver/tcpm/nct38xx.h index 9fafd611bb..9c131e10ec 100644 --- a/driver/tcpm/nct38xx.h +++ b/driver/tcpm/nct38xx.h @@ -40,6 +40,13 @@ #define NCT38XX_PRODUCT_ID 0xC301 +/* + * Default value from the ROLE_CTRL register on first boot will depend on + * whether we're coming from a dead battery state. + */ +#define NCT38XX_ROLE_CTRL_DEAD_BATTERY 0x0A +#define NCT39XX_ROLE_CTRL_GOOD_BATTERY 0x4A + #define NCT38XX_REG_GPIO_DATA_IN(n) (0xC0 + ((n) * 8)) #define NCT38XX_REG_GPIO_DATA_OUT(n) (0xC1 + ((n) * 8)) #define NCT38XX_REG_GPIO_DIR(n) (0xC2 + ((n) * 8)) @@ -88,6 +95,20 @@ void nct38xx_ioex_handle_alert(int ioex); */ int nct38xx_ioex_event_handler(int ioex); +enum nct38xx_boot_type { + NCT38XX_BOOT_UNKNOWN, + NCT38XX_BOOT_DEAD_BATTERY, + NCT38XX_BOOT_NORMAL, +}; + +/** + * Collect our boot type from the driver + * + * @param port USB-C port number + * @return Returns the boot type detected for this chip + */ +enum nct38xx_boot_type nct38xx_get_boot_type(int port); + extern const struct ioexpander_drv nct38xx_ioexpander_drv; #endif /* defined(__CROS_EC_USB_PD_TCPM_NCT38XX_H) */ |