diff options
author | Aseda Aboagye <aaboagye@google.com> | 2017-12-08 14:56:55 -0800 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2017-12-13 22:33:22 -0800 |
commit | 755517e2cfc213936107c60768455fd90748d75e (patch) | |
tree | da8241abbb58390eab4b25e78c364eff664bfcb0 /driver/ppc | |
parent | e167d36b75ab13892abaf865860a6674a5a09b59 (diff) | |
download | chrome-ec-755517e2cfc213936107c60768455fd90748d75e.tar.gz |
ppc: Add API to set Vbus source ILIM.
The PPC needs to update its Vbus source current limits whenever our
policy changes on the PD ports. This commit simply adds and API to do
so.
BUG=None
BRANCH=None
TEST=With some extra code to enable 3A out, flash zoombini; Plug in a PD
device to a port, verify that it gets 5V @ 3A. Plug in a second device,
verify that we re-send new source caps of 5V @ 1.5A.
TEST=Repeat above for meowth.
Change-Id: Ifa4bc8b7df87f7730f2bcded842906d43171394b
Signed-off-by: Aseda Aboagye <aaboagye@google.com>
Reviewed-on: https://chromium-review.googlesource.com/818335
Commit-Ready: Aseda Aboagye <aaboagye@chromium.org>
Tested-by: Aseda Aboagye <aaboagye@chromium.org>
Reviewed-by: Shawn N <shawnn@chromium.org>
Diffstat (limited to 'driver/ppc')
-rw-r--r-- | driver/ppc/sn5s330.c | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/driver/ppc/sn5s330.c b/driver/ppc/sn5s330.c index 1a06c830db..1f4d20eb76 100644 --- a/driver/ppc/sn5s330.c +++ b/driver/ppc/sn5s330.c @@ -444,6 +444,42 @@ static int sn5s330_is_sourcing_vbus(int port) return is_sourcing_vbus; } +static int sn5s330_set_vbus_source_current_limit(int port, + enum tcpc_rp_value rp) +{ + int regval; + int status; + + status = read_reg(port, SN5S330_FUNC_SET1, ®val); + if (status) + return status; + + /* + * Note that we chose the lowest current limit setting that is just + * above indicated Rp value. This is because these are minimum values + * and we must be able to provide the current that we advertise. + */ + regval &= ~0x1F; /* The current limit settings are 4:0. */ + switch (rp) { + case TYPEC_RP_3A0: + regval |= SN5S330_ILIM_3_06; + break; + + case TYPEC_RP_1A5: + regval |= SN5S330_ILIM_1_62; + break; + + case TYPEC_RP_USB: + default: + regval |= SN5S330_ILIM_0_63; + break; + }; + + status = write_reg(port, SN5S330_FUNC_SET1, regval); + + return status; +} + static int sn5s330_vbus_sink_enable(int port, int enable) { return sn5s330_pp_fet_enable(port, SN5S330_PP2, !!enable); @@ -503,4 +539,5 @@ const struct ppc_drv sn5s330_drv = { #ifdef CONFIG_USB_PD_VBUS_DETECT_PPC .is_vbus_present = &sn5s330_is_vbus_present, #endif /* defined(CONFIG_USB_PD_VBUS_DETECT_PPC) */ + .set_vbus_source_current_limit = &sn5s330_set_vbus_source_current_limit, }; |