diff options
author | Alec Berg <alecaberg@chromium.org> | 2015-05-06 09:53:32 -0700 |
---|---|---|
committer | ChromeOS Commit Bot <chromeos-commit-bot@chromium.org> | 2015-05-22 05:35:06 +0000 |
commit | 6fcd1c0481292b9df96f26bbb248248c697e2641 (patch) | |
tree | a470e921abfecad7c94bf0a3924365a066eeda36 /common | |
parent | 7c1231c55faa8880e6ec26e48d2cd342d280ee0f (diff) | |
download | chrome-ec-6fcd1c0481292b9df96f26bbb248248c697e2641.tar.gz |
pd: add config options for including TCPM and TCPC separately
Add config options for various parts of USB PD stack:
CONFIG_USB_POWER_DELIVERY: The use of this option has changed
slightly. It now represents whether or not to include the USB
PD protocol and policy layers of the software stack.
CONFIG_USB_PD_TCPC: Compile in type-C port controller module
which performs the phy layer of the PD stack.
CONFIG_USB_PD_TCPM_STUB and CONFIG_USB_PD_TCPM_TCPCI: If
CONFIG_USB_POWER_DELIVERY is defined, then one TCPM needs to
be defined to declare which port management module to use
to drive the TCPC.
BUG=none
BRANCH=none
TEST=make -j buildall
Change-Id: I41aa65a478e36925745cd37a6707f242c0dfbf91
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/270171
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Diffstat (limited to 'common')
-rw-r--r-- | common/build.mk | 5 | ||||
-rw-r--r-- | common/usb_pd_protocol.c | 10 | ||||
-rw-r--r-- | common/usb_pd_tcpc.c | 19 |
3 files changed, 23 insertions, 11 deletions
diff --git a/common/build.mk b/common/build.mk index 09e2c56c17..395844c527 100644 --- a/common/build.mk +++ b/common/build.mk @@ -81,8 +81,11 @@ common-$(CONFIG_SW_CRC)+=crc.o common-$(CONFIG_TEMP_SENSOR)+=temp_sensor.o thermal.o throttle_ap.o common-$(CONFIG_USB_PORT_POWER_DUMB)+=usb_port_power_dumb.o common-$(CONFIG_USB_PORT_POWER_SMART)+=usb_port_power_smart.o -common-$(CONFIG_USB_POWER_DELIVERY)+=usb_pd_protocol.o usb_pd_policy.o usb_pd_tcpm_stub.o usb_pd_tcpc.o +common-$(CONFIG_USB_POWER_DELIVERY)+=usb_pd_protocol.o usb_pd_policy.o common-$(CONFIG_USB_PD_LOGGING)+=pd_log.o +common-$(CONFIG_USB_PD_TCPC)+=usb_pd_tcpc.o +common-$(CONFIG_USB_PD_TCPM_STUB)+=usb_pd_tcpm_stub.o +common-$(CONFIG_USB_PD_TCPM_TCPCI)+=usb_pd_tcpm.o common-$(CONFIG_VBOOT_HASH)+=sha256.o vboot_hash.o common-$(CONFIG_WIRELESS)+=wireless.o common-$(HAS_TASK_CHIPSET)+=chipset.o diff --git a/common/usb_pd_protocol.c b/common/usb_pd_protocol.c index cbe4502b84..0bd0b6169a 100644 --- a/common/usb_pd_protocol.c +++ b/common/usb_pd_protocol.c @@ -1293,8 +1293,10 @@ void pd_task(void) /* Ensure the power supply is in the default state */ pd_power_supply_reset(port); +#ifdef CONFIG_USB_PD_TCPC /* Initialize port controller */ tcpc_init(port); +#endif /* Initialize PD protocol state variables for each port. */ pd[port].power_role = PD_ROLE_DEFAULT; @@ -1332,11 +1334,13 @@ void pd_task(void) /* wait for next event/packet or timeout expiration */ evt = task_wait_event(timeout); +#ifdef CONFIG_USB_PD_TCPC /* * run port controller task to check CC and/or read incoming * messages */ tcpc_run(port, evt); +#endif /* process any potential incoming message */ incoming_packet = evt & PD_EVENT_RX; @@ -1776,6 +1780,11 @@ void pd_task(void) } break; case PD_STATE_SUSPENDED: + /* + * TODO: Suspend state only supported if we are also + * the TCPC. + */ +#ifdef CONFIG_USB_PD_TCPC pd_rx_disable_monitoring(port); pd_hw_release(port); pd_power_supply_reset(port); @@ -1785,6 +1794,7 @@ void pd_task(void) task_wait_event(-1); pd_hw_init(port, PD_ROLE_DEFAULT); +#endif break; case PD_STATE_SNK_DISCONNECTED: timeout = 10*MSEC; diff --git a/common/usb_pd_tcpc.c b/common/usb_pd_tcpc.c index 13e78f5743..4e72de34d3 100644 --- a/common/usb_pd_tcpc.c +++ b/common/usb_pd_tcpc.c @@ -781,11 +781,10 @@ int tcpc_run(int port, int evt) return 10*MSEC; } -#if 0 -/* TODO: if we don't have TCPM on same CPU, we will need this task */ -void pd_phy_task(void) +#ifndef CONFIG_USB_POWER_DELIVERY +void pd_task(void) { - int port = TASK_ID_TO_PORT_PHY(task_get_current()); + int port = TASK_ID_TO_PORT(task_get_current()); int timeout = 10*MSEC; int evt; @@ -839,10 +838,10 @@ void tcpc_set_cc(int port, int pull) /* Wake the PD phy task with special CC event mask */ /* TODO: use top case if no TCPM on same CPU */ -#if 0 - task_set_event(PORT_PHY_TO_TASK_ID(port), PD_EVENT_CC, 0); -#else +#ifdef CONFIG_USB_POWER_DELIVERY tcpc_run(port, PD_EVENT_CC); +#else + task_set_event(PORT_TO_TASK_ID(port), PD_EVENT_CC, 0); #endif } @@ -872,10 +871,10 @@ void tcpc_transmit(int port, enum tcpm_transmit_type type, uint16_t header, pd[port].tx_head = header; pd[port].tx_data = data; /* TODO: use top case if no TCPM on same CPU */ -#if 0 - task_set_event(PORT_PHY_TO_TASK_ID(port), PD_EVENT_TX, 0); -#else +#ifdef CONFIG_USB_POWER_DELIVERY tcpc_run(port, PD_EVENT_TX); +#else + task_set_event(PORT_TO_TASK_ID(port), PD_EVENT_TX, 0); #endif } |