diff options
author | Aseda Aboagye <aaboagye@google.com> | 2017-11-30 00:02:20 -0800 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2017-12-06 17:30:46 -0800 |
commit | eff4baf03f28f04cf1e89a602fe3a244228cbb6e (patch) | |
tree | 84a20fe7679ad083133be0c1b47617b7543e67cb /driver/ppc | |
parent | 0dd7716c4f8fbd73e57060d32badf4b2c3767678 (diff) | |
download | chrome-ec-eff4baf03f28f04cf1e89a602fe3a244228cbb6e.tar.gz |
sn5s330: Add support for Vbus detection.
The SN5S330 has support for detecting when Vbus is present on a port.
This commit simply adds an API to query the PPC.
BUG=None
BRANCH=None
TEST=`make -j buildall`.
TEST=Flash a board with the SN5S330, with some extra code, verify that
Vbus can be detected with this API.
Change-Id: I45bf7ff24bcdc447efe12932f51f8094108e29d5
Signed-off-by: Aseda Aboagye <aaboagye@google.com>
Reviewed-on: https://chromium-review.googlesource.com/791502
Commit-Ready: Aseda Aboagye <aaboagye@chromium.org>
Tested-by: Aseda Aboagye <aaboagye@chromium.org>
Reviewed-by: Edward Hill <ecgh@chromium.org>
Reviewed-by: Shawn N <shawnn@chromium.org>
Diffstat (limited to 'driver/ppc')
-rw-r--r-- | driver/ppc/sn5s330.c | 25 | ||||
-rw-r--r-- | driver/ppc/sn5s330.h | 3 |
2 files changed, 23 insertions, 5 deletions
diff --git a/driver/ppc/sn5s330.c b/driver/ppc/sn5s330.c index 2949a74a99..f261f434ca 100644 --- a/driver/ppc/sn5s330.c +++ b/driver/ppc/sn5s330.c @@ -122,14 +122,12 @@ static int sn5s330_is_pp_fet_enabled(uint8_t port, enum sn5s330_pp_idx pp, int status; int regval; - if (pp == SN5S330_PP1) { + if (pp == SN5S330_PP1) pp_bit = SN5S330_PP1_EN; - } else if (pp == SN5S330_PP2) { + else if (pp == SN5S330_PP2) pp_bit = SN5S330_PP2_EN; - } else { - CPRINTF("bad PP idx(%d)!", pp); + else return EC_ERROR_INVAL; - } status = get_func_set3(port, ®val); if (status) @@ -415,6 +413,20 @@ static int sn5s330_init(int port) return EC_SUCCESS; } +#ifdef CONFIG_USB_PD_VBUS_DETECT_PPC +static int sn5s330_is_vbus_present(int port, int *vbus_present) +{ + int regval; + int rv; + + rv = read_reg(port, SN5S330_INT_STATUS_REG3, ®val); + if (!rv) + *vbus_present = !!(regval & SN5S330_VBUS_GOOD); + + return rv; +} +#endif /* defined(CONFIG_USB_PD_VBUS_DETECT_PPC) */ + static int sn5s330_is_sourcing_vbus(int port) { int is_sourcing_vbus = 0; @@ -448,4 +460,7 @@ const struct ppc_drv sn5s330_drv = { #ifdef CONFIG_CMD_PPC_DUMP .reg_dump = &sn5s330_dump, #endif /* defined(CONFIG_CMD_PPC_DUMP) */ +#ifdef CONFIG_USB_PD_VBUS_DETECT_PPC + .is_vbus_present = &sn5s330_is_vbus_present, +#endif /* defined(CONFIG_USB_PD_VBUS_DETECT_PPC) */ }; diff --git a/driver/ppc/sn5s330.h b/driver/ppc/sn5s330.h index 059df14a30..683c3f6807 100644 --- a/driver/ppc/sn5s330.h +++ b/driver/ppc/sn5s330.h @@ -100,6 +100,9 @@ enum sn5s330_pp_idx { #define SN5S330_PP2_CONFIG (1 << 2) #define SN5S330_OVP_EN_CC (1 << 4) +/* INT_STATUS_REG3 */ +#define SN5S330_VBUS_GOOD (1 << 0) + /* INT_STATUS_REG4 */ #define SN5S330_DIG_RES (1 << 0) #define SN5S330_DB_BOOT (1 << 1) |