summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlec Berg <alecaberg@chromium.org>2015-05-06 09:53:32 -0700
committerChromeOS Commit Bot <chromeos-commit-bot@chromium.org>2015-05-22 05:35:06 +0000
commit6fcd1c0481292b9df96f26bbb248248c697e2641 (patch)
treea470e921abfecad7c94bf0a3924365a066eeda36
parent7c1231c55faa8880e6ec26e48d2cd342d280ee0f (diff)
downloadchrome-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>
-rw-r--r--board/dingdong/board.h2
-rw-r--r--board/firefly/board.h2
-rw-r--r--board/fruitpie/board.h2
-rw-r--r--board/hoho/board.h2
-rw-r--r--board/honeybuns/board.h2
-rw-r--r--board/plankton/board.h2
-rw-r--r--board/ryu/board.h2
-rw-r--r--board/ryu_p4p5/board.h2
-rw-r--r--board/samus_pd/board.h2
-rw-r--r--board/twinkie/board.h2
-rw-r--r--board/zinger/board.h2
-rw-r--r--chip/stm32/build.mk2
-rw-r--r--common/build.mk5
-rw-r--r--common/usb_pd_protocol.c10
-rw-r--r--common/usb_pd_tcpc.c19
-rw-r--r--include/config.h11
-rw-r--r--test/test_config.h2
17 files changed, 59 insertions, 12 deletions
diff --git a/board/dingdong/board.h b/board/dingdong/board.h
index 666ab2699e..77b557b4b1 100644
--- a/board/dingdong/board.h
+++ b/board/dingdong/board.h
@@ -38,6 +38,8 @@
#define CONFIG_USB_PD_NO_VBUS_DETECT
#define CONFIG_USB_PD_LOGGING
#define CONFIG_USB_PD_LOG_SIZE 256
+#define CONFIG_USB_PD_TCPC
+#define CONFIG_USB_PD_TCPM_STUB
#undef CONFIG_WATCHDOG_HELP
#undef CONFIG_LID_SWITCH
#undef CONFIG_TASK_PROFILING
diff --git a/board/firefly/board.h b/board/firefly/board.h
index a9bd7b47ee..43b324c0d3 100644
--- a/board/firefly/board.h
+++ b/board/firefly/board.h
@@ -19,6 +19,8 @@
#define CONFIG_USB_POWER_DELIVERY
#define CONFIG_USB_PD_DUAL_ROLE
#define CONFIG_USB_PD_INTERNAL_COMP
+#define CONFIG_USB_PD_TCPC
+#define CONFIG_USB_PD_TCPM_STUB
#define CONFIG_ADC
#define CONFIG_HW_CRC
#define CONFIG_I2C
diff --git a/board/fruitpie/board.h b/board/fruitpie/board.h
index ea5cb59d24..a2213baa1c 100644
--- a/board/fruitpie/board.h
+++ b/board/fruitpie/board.h
@@ -24,6 +24,8 @@
#define CONFIG_USB_PD_CUSTOM_VDM
#define CONFIG_USB_PD_DUAL_ROLE
#define CONFIG_USB_PD_INTERNAL_COMP
+#define CONFIG_USB_PD_TCPC
+#define CONFIG_USB_PD_TCPM_STUB
#define CONFIG_USBC_SS_MUX
#define CONFIG_USBC_VCONN
#define CONFIG_ADC
diff --git a/board/hoho/board.h b/board/hoho/board.h
index 58dc4db20a..4ce3a5320e 100644
--- a/board/hoho/board.h
+++ b/board/hoho/board.h
@@ -44,6 +44,8 @@
#define CONFIG_USB_PD_IDENTITY_SW_VERS 1
#define CONFIG_USB_PD_LOGGING
#define CONFIG_USB_PD_LOG_SIZE 256
+#define CONFIG_USB_PD_TCPC
+#define CONFIG_USB_PD_TCPM_STUB
#define CONFIG_USB_PD_NO_VBUS_DETECT
/* mcdp2850 serial interface */
#define CONFIG_MCDP28X0 usart3_hw
diff --git a/board/honeybuns/board.h b/board/honeybuns/board.h
index 781467144b..bf31953269 100644
--- a/board/honeybuns/board.h
+++ b/board/honeybuns/board.h
@@ -29,6 +29,8 @@
#define CONFIG_USB_PD_CUSTOM_VDM
#define CONFIG_USB_PD_DUAL_ROLE
#define CONFIG_USB_PD_INTERNAL_COMP
+#define CONFIG_USB_PD_TCPC
+#define CONFIG_USB_PD_TCPM_STUB
#define CONFIG_USBC_SS_MUX
#define CONFIG_USBC_VCONN
#undef CONFIG_WATCHDOG_HELP
diff --git a/board/plankton/board.h b/board/plankton/board.h
index 7b796b919e..25826395eb 100644
--- a/board/plankton/board.h
+++ b/board/plankton/board.h
@@ -25,6 +25,8 @@
#define CONFIG_USB_PD_IDENTITY_SW_VERS 1
#define CONFIG_USB_PD_INTERNAL_COMP
#define CONFIG_USB_PD_DYNAMIC_SRC_CAP
+#define CONFIG_USB_PD_TCPC
+#define CONFIG_USB_PD_TCPM_STUB
#define CONFIG_ADC
#define CONFIG_HW_CRC
#define CONFIG_I2C
diff --git a/board/ryu/board.h b/board/ryu/board.h
index 327b8b8055..61beea4afc 100644
--- a/board/ryu/board.h
+++ b/board/ryu/board.h
@@ -30,6 +30,8 @@
#define CONFIG_USB_PD_DUAL_ROLE
#define CONFIG_USB_PD_FLASH_ERASE_CHECK
#define CONFIG_USB_PD_INTERNAL_COMP
+#define CONFIG_USB_PD_TCPC
+#define CONFIG_USB_PD_TCPM_STUB
#define CONFIG_USB_SWITCH_PI3USB9281
#define CONFIG_USBC_SS_MUX
#define CONFIG_USBC_VCONN
diff --git a/board/ryu_p4p5/board.h b/board/ryu_p4p5/board.h
index 6c5479d49a..44816b4848 100644
--- a/board/ryu_p4p5/board.h
+++ b/board/ryu_p4p5/board.h
@@ -29,6 +29,8 @@
#define CONFIG_USB_PD_DUAL_ROLE
#define CONFIG_USB_PD_FLASH_ERASE_CHECK
#define CONFIG_USB_PD_INTERNAL_COMP
+#define CONFIG_USB_PD_TCPC
+#define CONFIG_USB_PD_TCPM_STUB
#define CONFIG_USB_SWITCH_PI3USB9281
#define CONFIG_USBC_SS_MUX
#define CONFIG_USBC_VCONN
diff --git a/board/samus_pd/board.h b/board/samus_pd/board.h
index 5e48b5e53a..5585055f35 100644
--- a/board/samus_pd/board.h
+++ b/board/samus_pd/board.h
@@ -57,6 +57,8 @@
#define CONFIG_USB_PD_INTERNAL_COMP
#define CONFIG_USB_PD_LOGGING
#define CONFIG_USB_PD_LOG_SIZE 512
+#define CONFIG_USB_PD_TCPC
+#define CONFIG_USB_PD_TCPM_STUB
#define CONFIG_USB_SWITCH_PI3USB9281
#undef CONFIG_USB_SWITCH_PI3USB9281_MUX_GPIO
#define CONFIG_USB_SWITCH_PI3USB9281_MUX_GPIO GPIO_USB_C_BC12_SEL
diff --git a/board/twinkie/board.h b/board/twinkie/board.h
index 992eeb83f1..d8550ff9cd 100644
--- a/board/twinkie/board.h
+++ b/board/twinkie/board.h
@@ -21,6 +21,8 @@
#define CONFIG_USB_POWER_DELIVERY
#define CONFIG_USB_PD_DUAL_ROLE
#define CONFIG_USB_PD_INTERNAL_COMP
+#define CONFIG_USB_PD_TCPC
+#define CONFIG_USB_PD_TCPM_STUB
#define CONFIG_PD_USE_DAC_AS_REF
#define CONFIG_HW_CRC
diff --git a/board/zinger/board.h b/board/zinger/board.h
index bd9c472368..49a8064c36 100644
--- a/board/zinger/board.h
+++ b/board/zinger/board.h
@@ -57,6 +57,8 @@
#undef CONFIG_USB_PD_INTERNAL_COMP
#define CONFIG_USB_PD_LOGGING
#define CONFIG_USB_PD_LOG_SIZE 256
+#define CONFIG_USB_PD_TCPC
+#define CONFIG_USB_PD_TCPM_STUB
#undef CONFIG_USB_PD_RX_COMP_IRQ
#define CONFIG_USB_PD_SIMPLE_DFP
#define CONFIG_USBC_BACKWARDS_COMPATIBLE_DFP
diff --git a/chip/stm32/build.mk b/chip/stm32/build.mk
index f2cb2d9983..326edfb830 100644
--- a/chip/stm32/build.mk
+++ b/chip/stm32/build.mk
@@ -52,5 +52,5 @@ chip-$(CONFIG_USB)+=usb.o usb-$(CHIP_FAMILY).o usb_endpoints.o
chip-$(CONFIG_USB_CONSOLE)+=usb_console.o
chip-$(CONFIG_USB_GPIO)+=usb_gpio.o
chip-$(CONFIG_USB_HID)+=usb_hid.o
-chip-$(CONFIG_USB_POWER_DELIVERY)+=usb_pd_phy.o
+chip-$(CONFIG_USB_PD_TCPC)+=usb_pd_phy.o
chip-$(CONFIG_USB_SPI)+=usb_spi.o
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
}
diff --git a/include/config.h b/include/config.h
index 53232410ac..5acc7d57ea 100644
--- a/include/config.h
+++ b/include/config.h
@@ -1334,6 +1334,17 @@
/* Use comparator module for PD RX interrupt */
#define CONFIG_USB_PD_RX_COMP_IRQ
+/* Use TCPC module (type-C port controller) */
+#undef CONFIG_USB_PD_TCPC
+
+/*
+ * Choose one of the following TCPMs (type-C port manager) to manage TCPC. The
+ * TCPM stub is used to make direct function calls to TCPC when TCPC is on
+ * the same MCU. The TCPCI TCPM uses the standard TCPCI i2c interface to TCPC.
+ */
+#undef CONFIG_USB_PD_TCPM_STUB
+#undef CONFIG_USB_PD_TCPM_TCPCI
+
/* Alternative configuration keeping only the TX part of PHY */
#undef CONFIG_USB_PD_TX_PHY_ONLY
diff --git a/test/test_config.h b/test/test_config.h
index efaf0ef3b6..6117a6c0dc 100644
--- a/test/test_config.h
+++ b/test/test_config.h
@@ -130,6 +130,8 @@ int board_discharge_on_ac(int enabled);
#define CONFIG_USB_POWER_DELIVERY
#define CONFIG_USB_PD_CUSTOM_VDM
#define CONFIG_USB_PD_DUAL_ROLE
+#define CONFIG_USB_PD_TCPC
+#define CONFIG_USB_PD_TCPM_STUB
#define CONFIG_SHA256
#define CONFIG_SW_CRC
#endif