diff options
author | Sunway <lisunwei@huaqin.corp-partner.google.com> | 2021-06-28 14:39:33 +0800 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2021-07-08 03:15:06 +0000 |
commit | 109c9d6556260dbe067ea9a2cff879db674524c1 (patch) | |
tree | 23dba72cc9da713d3f1913f1d6455c786f158c19 /board/cappy2/usb_pd_policy.c | |
parent | 1ce3910f7dfbff10386c4b02d7025c3bfd11ef5e (diff) | |
download | chrome-ec-109c9d6556260dbe067ea9a2cff879db674524c1.tar.gz |
cappy2: Initial EC image
Create the initial EC image for the cappy2 variant by copying the
lalala reference board EC files into a new directory named for
the variant.
(Auto-Generated by create_initial_ec_image.sh version 1.5.0).
BUG=b:192035460
BRANCH=None
TEST=make BOARD=cappy2
Signed-off-by: Sunway <lisunwei@huaqin.corp-partner.google.com>
Change-Id: I402e5425f25b07122a84294f9f413e576683952a
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2992609
Tested-by: Tao Xia <xiatao5@huaqin.corp-partner.google.com>
Reviewed-by: Weimin Wu <wuweimin@huaqin.corp-partner.google.com>
Reviewed-by: Henry Sun <henrysun@google.com>
Reviewed-by: Bob Moragues <moragues@chromium.org>
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
Commit-Queue: Aseda Aboagye <aaboagye@chromium.org>
Diffstat (limited to 'board/cappy2/usb_pd_policy.c')
-rw-r--r-- | board/cappy2/usb_pd_policy.c | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/board/cappy2/usb_pd_policy.c b/board/cappy2/usb_pd_policy.c new file mode 100644 index 0000000000..fd9018a3f0 --- /dev/null +++ b/board/cappy2/usb_pd_policy.c @@ -0,0 +1,56 @@ +/* Copyright 2021 The Chromium OS Authors. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include "charge_manager.h" +#include "chipset.h" +#include "common.h" +#include "console.h" +#include "driver/tcpm/tcpci.h" +#include "usb_pd.h" + +#define CPRINTF(format, args...) cprintf(CC_USBPD, format, ## args) +#define CPRINTS(format, args...) cprints(CC_USBPD, format, ## args) + +int pd_check_vconn_swap(int port) +{ + /* Allow VCONN swaps if the AP is on. */ + return chipset_in_state(CHIPSET_STATE_ANY_SUSPEND | CHIPSET_STATE_ON); +} + +void pd_power_supply_reset(int port) +{ + /* Disable VBUS */ + tcpc_write(port, TCPC_REG_COMMAND, TCPC_REG_COMMAND_SRC_CTRL_LOW); + + /* Notify host of power info change. */ + pd_send_host_event(PD_EVENT_POWER_CHANGE); +} + +int pd_set_power_supply_ready(int port) +{ + int rv; + + if (port >= CONFIG_USB_PD_PORT_MAX_COUNT) + return EC_ERROR_INVAL; + + /* Disable charging. */ + rv = tcpc_write(port, TCPC_REG_COMMAND, TCPC_REG_COMMAND_SNK_CTRL_LOW); + if (rv) + return rv; + + /* Our policy is not to source VBUS when the AP is off. */ + if (chipset_in_state(CHIPSET_STATE_ANY_OFF)) + return EC_ERROR_NOT_POWERED; + + /* Provide Vbus. */ + rv = tcpc_write(port, TCPC_REG_COMMAND, TCPC_REG_COMMAND_SRC_CTRL_HIGH); + if (rv) + return rv; + + /* Notify host of power info change. */ + pd_send_host_event(PD_EVENT_POWER_CHANGE); + + return EC_SUCCESS; +} |