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>
This commit is contained in:
Alec Berg
2015-05-06 09:53:32 -07:00
committed by ChromeOS Commit Bot
parent 7c1231c55f
commit 6fcd1c0481
17 changed files with 59 additions and 12 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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;

View File

@@ -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
}

View File

@@ -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

View File

@@ -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