summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorScott Collyer <scollyer@google.com>2022-10-04 16:15:59 -0700
committerChromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com>2022-11-03 18:15:02 +0000
commit290a6ce0d426f6477c94e6cb4c125694782370f6 (patch)
tree821bcd74c965d15edc6d6b5ff789868543653d92
parent339879506fdc0d515c27e4dc4d2fe776f30de4e2 (diff)
downloadchrome-ec-290a6ce0d426f6477c94e6cb4c125694782370f6.tar.gz
tcpmv2: dpm: Convert dpm_run to a 1st class SM framework
This CL adds a type-c state machine framework for the Device Policy Manager (dpm) layer of USB-PD. This CL is focused just on adding the state machine policy and minimizing any changes in the existing DPM support functions. Because the DPM is no longer being called directly from the PE layer, an interlock mechanism is used to control when the DPM state machine will take any actions. This CL also renames include/usb_pd_dpm.h to include/usb_pd_dpm_sm.h to be consistent with include file naming for the other TCPMv2 layer state machine include files. BUG=b:194504052 BRANCH=none TEST=Verified that mode entry/exit is successful for DP, TBT, and USB4 on Voxel. ectool typeccontrol <port> 0 -> exit mode ectool typeccontrol <port> 2 0 -> DP ectool typeccontrol <port> 2 1 -> TBT ectool typeccontrol <port> 2 2 -> USB4 Signed-off-by: Scott Collyer <scollyer@google.com> Change-Id: I196d342b031b96874d354610182be79eac613d00 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3922467 Reviewed-by: Abe Levkoy <alevkoy@chromium.org> Tested-by: Scott Collyer <scollyer@chromium.org> Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com> Commit-Queue: Scott Collyer <scollyer@chromium.org>
-rw-r--r--board/chocodile_vpdmcu/board.h1
-rw-r--r--common/charge_manager.c2
-rw-r--r--common/mock/usb_pd_dpm_mock.c6
-rw-r--r--common/usb_common.c2
-rw-r--r--common/usbc/usb_mode.c2
-rw-r--r--common/usbc/usb_pd_console.c2
-rw-r--r--common/usbc/usb_pd_dpm.c164
-rw-r--r--common/usbc/usb_pd_host.c2
-rw-r--r--common/usbc/usb_pe_drp_sm.c24
-rw-r--r--common/usbc/usb_tc_drp_acc_trysrc_sm.c2
-rw-r--r--common/usbc/usbc_task.c5
-rw-r--r--include/config.h2
-rw-r--r--include/mock/usb_pd_dpm_mock.h2
-rw-r--r--include/usb_dp_alt_mode.h2
-rw-r--r--include/usb_pd_dpm_sm.h (renamed from include/usb_pd_dpm.h)24
-rw-r--r--include/usb_tbt_alt_mode.h2
-rw-r--r--test/fake_usbc.c6
-rw-r--r--test/test_config.h4
-rw-r--r--zephyr/Kconfig.pd9
-rw-r--r--zephyr/shim/include/config_chip.h5
-rw-r--r--zephyr/test/drivers/default/src/console_cmd/usb_pd_console.c2
21 files changed, 227 insertions, 43 deletions
diff --git a/board/chocodile_vpdmcu/board.h b/board/chocodile_vpdmcu/board.h
index ede07dd9a0..596407628e 100644
--- a/board/chocodile_vpdmcu/board.h
+++ b/board/chocodile_vpdmcu/board.h
@@ -72,6 +72,7 @@
#define CONFIG_USB_PD_DECODE_SOP
#define CONFIG_USB_PD_DUAL_ROLE
#define CONFIG_USB_PD_INTERNAL_COMP
+#undef CONFIG_USB_DPM_SM
#define CONFIG_VBOOT_HASH
#define CONFIG_WATCHDOG
#undef CONFIG_WATCHDOG_HELP
diff --git a/common/charge_manager.c b/common/charge_manager.c
index 3e8b937e53..b28a186ef8 100644
--- a/common/charge_manager.c
+++ b/common/charge_manager.c
@@ -23,7 +23,7 @@
#include "typec_control.h"
#include "usb_common.h"
#include "usb_pd.h"
-#include "usb_pd_dpm.h"
+#include "usb_pd_dpm_sm.h"
#include "usb_pd_tcpm.h"
#include "util.h"
diff --git a/common/mock/usb_pd_dpm_mock.c b/common/mock/usb_pd_dpm_mock.c
index 158c53c650..03c18f37a1 100644
--- a/common/mock/usb_pd_dpm_mock.c
+++ b/common/mock/usb_pd_dpm_mock.c
@@ -49,7 +49,7 @@ void dpm_set_mode_exit_request(int port)
{
}
-void dpm_run(int port)
+void dpm_run(int port, int evt, int en)
{
}
@@ -95,3 +95,7 @@ int dpm_get_status_msg(int port, uint8_t *msg, uint32_t *len)
void dpm_handle_alert(int port, uint32_t ado)
{
}
+
+void dpm_set_pe_ready(int port, bool enable)
+{
+}
diff --git a/common/usb_common.c b/common/usb_common.c
index edede7c303..2ef12e9412 100644
--- a/common/usb_common.c
+++ b/common/usb_common.c
@@ -27,7 +27,7 @@
#include "usb_common.h"
#include "usb_mux.h"
#include "usb_pd.h"
-#include "usb_pd_dpm.h"
+#include "usb_pd_dpm_sm.h"
#include "usb_pd_flags.h"
#include "usb_pd_tcpm.h"
#include "usb_pe_sm.h"
diff --git a/common/usbc/usb_mode.c b/common/usbc/usb_mode.c
index 8f4824e4e9..f9b50c8fae 100644
--- a/common/usbc/usb_mode.c
+++ b/common/usbc/usb_mode.c
@@ -19,7 +19,7 @@
#include "usb_mode.h"
#include "usb_mux.h"
#include "usb_pd.h"
-#include "usb_pd_dpm.h"
+#include "usb_pd_dpm_sm.h"
#include "usb_pd_tcpm.h"
#include "usb_pe_sm.h"
#include "usb_tbt_alt_mode.h"
diff --git a/common/usbc/usb_pd_console.c b/common/usbc/usb_pd_console.c
index 89a5492ad5..c7eb215572 100644
--- a/common/usbc/usb_pd_console.c
+++ b/common/usbc/usb_pd_console.c
@@ -6,7 +6,7 @@
#include "common.h"
#include "console.h"
#include "usb_common.h"
-#include "usb_pd_dpm.h"
+#include "usb_pd_dpm_sm.h"
#include "usb_pd_timer.h"
#include "usb_pe_sm.h"
#include "usb_prl_sm.h"
diff --git a/common/usbc/usb_pd_dpm.c b/common/usbc/usb_pd_dpm.c
index daccc2ba2a..e9963811fc 100644
--- a/common/usbc/usb_pd_dpm.c
+++ b/common/usbc/usb_pd_dpm.c
@@ -25,11 +25,12 @@
#include "usb_mode.h"
#include "usb_mux.h"
#include "usb_pd.h"
-#include "usb_pd_dpm.h"
#include "usb_pd_pdo.h"
#include "usb_pd_tcpm.h"
#include "usb_pd_timer.h"
#include "usb_pe_sm.h"
+#include "usb_pd_dpm_sm.h"
+#include "usb_tc_sm.h"
#include "usb_tbt_alt_mode.h"
#ifdef CONFIG_ZEPHYR
@@ -48,6 +49,8 @@
#define DPM_ATTENION_MAX_VDO 2
static struct {
+ /* state machine context */
+ struct sm_ctx ctx;
atomic_t flags;
uint32_t vdm_req[VDO_MAX_SIZE];
int vdm_req_cnt;
@@ -73,6 +76,44 @@ static struct {
#define DPM_FLAG_DATA_RESET_DONE BIT(7)
#define DPM_FLAG_PD_BUTTON_PRESSED BIT(8)
#define DPM_FLAG_PD_BUTTON_RELEASED BIT(9)
+#define DPM_FLAG_PE_READY BIT(10)
+
+/* List of all Device Policy Manager level states */
+enum usb_dpm_state {
+ /* Normal States */
+ DPM_WAITING,
+ DPM_READY,
+};
+
+/* Forward declare the full list of states. This is indexed by usb_pd_state */
+static const struct usb_state dpm_states[];
+
+/* List of human readable state names for console debugging */
+__maybe_unused static __const_data const char *const dpm_state_names[] = {
+ /* Normal States */
+ [DPM_WAITING] = "DPM Waiting",
+ [DPM_READY] = "DPM Ready",
+};
+
+static enum sm_local_state local_state[CONFIG_USB_PD_PORT_MAX_COUNT];
+
+/* Set the DPM state machine to a new state. */
+static void set_state_dpm(const int port, const enum usb_dpm_state new_state)
+{
+ set_state(port, &dpm[port].ctx, &dpm_states[new_state]);
+}
+
+/* Get the current TypeC state. */
+__maybe_unused test_export_static enum usb_dpm_state
+get_state_dpm(const int port)
+{
+ return dpm[port].ctx.current - &dpm_states[0];
+}
+
+static void print_current_state(const int port)
+{
+ CPRINTS("C%d: %s", port, dpm_state_names[get_state_dpm(port)]);
+}
#ifdef CONFIG_ZEPHYR
static int init_vdm_req_mutex(const struct device *dev)
@@ -180,6 +221,9 @@ void dpm_init(int port)
{
dpm[port].flags = 0;
dpm[port].pd_button_state = DPM_PD_BUTTON_IDLE;
+
+ /* Ensure that DPM state machine gets reset */
+ set_state_dpm(port, DPM_WAITING);
}
void dpm_mode_exit_complete(int port)
@@ -208,6 +252,18 @@ void dpm_data_reset_complete(int port)
DPM_CLR_FLAG(port, DPM_FLAG_MODE_ENTRY_DONE);
}
+void dpm_set_pe_ready(int port, bool enable)
+{
+ /*
+ * DPM should remain DPM_WAITING state until the PE is in its ready
+ * state and is able to accept requests from the DPM layer.
+ */
+ if (enable)
+ DPM_SET_FLAG(port, DPM_FLAG_PE_READY);
+ else
+ DPM_CLR_FLAG(port, DPM_FLAG_PE_READY);
+}
+
static void dpm_clear_mode_exit_request(int port)
{
DPM_CLR_FLAG(port, DPM_FLAG_EXIT_REQUEST);
@@ -640,24 +696,6 @@ static void dpm_run_pd_button_sm(int port)
DPM_CLR_FLAG(port, DPM_FLAG_PD_BUTTON_RELEASED);
}
-void dpm_run(int port)
-{
- if (pd_get_data_role(port) == PD_ROLE_DFP) {
- /* Run DFP related DPM requests */
- if (DPM_CHK_FLAG(port, DPM_FLAG_EXIT_REQUEST))
- dpm_attempt_mode_exit(port);
- else if (!DPM_CHK_FLAG(port, DPM_FLAG_MODE_ENTRY_DONE))
- dpm_attempt_mode_entry(port);
-
- /* Run USB PD Power button state machine */
- dpm_run_pd_button_sm(port);
- }
-
- /* Run any VDM REQ messages */
- if (DPM_CHK_FLAG(port, DPM_FLAG_SEND_VDM_REQ))
- dpm_send_req_vdm(port);
-}
-
/*
* Source-out policy variables and APIs
*
@@ -1199,3 +1237,91 @@ uint8_t pd_get_bist_share_mode(void)
{
return bist_shared_mode_enabled;
}
+
+void dpm_run(int port, int evt, int en)
+{
+ switch (local_state[port]) {
+ case SM_PAUSED:
+ if (!en)
+ break;
+ __fallthrough;
+ case SM_INIT:
+ dpm_init(port);
+ local_state[port] = SM_RUN;
+ __fallthrough;
+ case SM_RUN:
+ if (!en) {
+ local_state[port] = SM_PAUSED;
+ /*
+ * While we are paused, exit all states and wait until
+ * initialized again.
+ */
+ set_state(port, &dpm[port].ctx, NULL);
+ break;
+ }
+
+ /* Run state machine */
+ run_state(port, &dpm[port].ctx);
+
+ break;
+ }
+}
+
+/*
+ * DPM_WAITING
+ */
+static void dpm_waiting_entry(const int port)
+{
+ DPM_CLR_FLAG(port, DPM_FLAG_PE_READY);
+ print_current_state(port);
+}
+
+static void dpm_waiting_run(const int port)
+{
+ if (DPM_CHK_FLAG(port, DPM_FLAG_PE_READY)) {
+ set_state_dpm(port, DPM_READY);
+ }
+}
+
+/*
+ * DPM_READY
+ */
+static void dpm_ready_entry(const int port)
+{
+ print_current_state(port);
+}
+
+static void dpm_ready_run(const int port)
+{
+ if (!DPM_CHK_FLAG(port, DPM_FLAG_PE_READY)) {
+ set_state_dpm(port, DPM_WAITING);
+ return;
+ }
+
+ if (pd_get_data_role(port) == PD_ROLE_DFP) {
+ /* Run DFP related DPM requests */
+ if (DPM_CHK_FLAG(port, DPM_FLAG_EXIT_REQUEST))
+ dpm_attempt_mode_exit(port);
+ else if (!DPM_CHK_FLAG(port, DPM_FLAG_MODE_ENTRY_DONE))
+ dpm_attempt_mode_entry(port);
+
+ /* Run USB PD Power button state machine */
+ dpm_run_pd_button_sm(port);
+ }
+
+ /* Run any VDM REQ messages */
+ if (DPM_CHK_FLAG(port, DPM_FLAG_SEND_VDM_REQ))
+ dpm_send_req_vdm(port);
+}
+
+static __const_data const struct usb_state dpm_states[] = {
+ /* Normal States */
+ [DPM_WAITING] = {
+ .entry = dpm_waiting_entry,
+ .run = dpm_waiting_run,
+ },
+ [DPM_READY] = {
+ .entry = dpm_ready_entry,
+ .run = dpm_ready_run,
+ },
+};
diff --git a/common/usbc/usb_pd_host.c b/common/usbc/usb_pd_host.c
index 502abc374a..93a8e573a0 100644
--- a/common/usbc/usb_pd_host.c
+++ b/common/usbc/usb_pd_host.c
@@ -12,7 +12,7 @@
#include "host_command.h"
#include "usb_mux.h"
#include "usb_pd.h"
-#include "usb_pd_dpm.h"
+#include "usb_pd_dpm_sm.h"
#include "usb_pd_tcpm.h"
#include "util.h"
diff --git a/common/usbc/usb_pe_drp_sm.c b/common/usbc/usb_pe_drp_sm.c
index f6cd95463f..c6a61f1bd9 100644
--- a/common/usbc/usb_pe_drp_sm.c
+++ b/common/usbc/usb_pe_drp_sm.c
@@ -27,7 +27,7 @@
#include "usb_dp_alt_mode.h"
#include "usb_mode.h"
#include "usb_mux.h"
-#include "usb_pd_dpm.h"
+#include "usb_pd_dpm_sm.h"
#include "usb_pd_policy.h"
#include "usb_pd.h"
#include "usb_pd_tcpm.h"
@@ -2927,11 +2927,17 @@ static void pe_src_ready_run(int port)
if (pe_attempt_port_discovery(port))
return;
- /* No DPM requests; attempt mode entry/exit if needed */
- dpm_run(port);
+ /* Inform DPM state machine that PE is set for messages */
+ dpm_set_pe_ready(port, true);
}
}
+static void pe_src_ready_exit(int port)
+{
+ /* Inform DPM state machine that PE is in ready state */
+ dpm_set_pe_ready(port, false);
+}
+
/**
* PE_SRC_Disabled
*/
@@ -3803,11 +3809,17 @@ static void pe_snk_ready_run(int port)
if (pe_attempt_port_discovery(port))
return;
- /* No DPM requests; attempt mode entry/exit if needed */
- dpm_run(port);
+ /* Inform DPM state machine that PE is set for messages */
+ dpm_set_pe_ready(port, true);
}
}
+static void pe_snk_ready_exit(int port)
+{
+ /* Inform DPM state machine that PE is in ready state */
+ dpm_set_pe_ready(port, false);
+}
+
/**
* PE_SNK_Hard_Reset
*/
@@ -7902,6 +7914,7 @@ static __const_data const struct usb_state pe_states[] = {
[PE_SRC_READY] = {
.entry = pe_src_ready_entry,
.run = pe_src_ready_run,
+ .exit = pe_src_ready_exit,
},
[PE_SRC_DISABLED] = {
.entry = pe_src_disabled_entry,
@@ -7948,6 +7961,7 @@ static __const_data const struct usb_state pe_states[] = {
[PE_SNK_READY] = {
.entry = pe_snk_ready_entry,
.run = pe_snk_ready_run,
+ .exit = pe_snk_ready_exit,
},
[PE_SNK_HARD_RESET] = {
.entry = pe_snk_hard_reset_entry,
diff --git a/common/usbc/usb_tc_drp_acc_trysrc_sm.c b/common/usbc/usb_tc_drp_acc_trysrc_sm.c
index ae84574b40..47369a75d1 100644
--- a/common/usbc/usb_tc_drp_acc_trysrc_sm.c
+++ b/common/usbc/usb_tc_drp_acc_trysrc_sm.c
@@ -17,7 +17,7 @@
#include "usb_common.h"
#include "usb_mux.h"
#include "usb_pd.h"
-#include "usb_pd_dpm.h"
+#include "usb_pd_dpm_sm.h"
#include "usb_pd_tcpm.h"
#include "usb_pd_timer.h"
#include "usb_pe_sm.h"
diff --git a/common/usbc/usbc_task.c b/common/usbc/usbc_task.c
index 6384aae879..ae5b401283 100644
--- a/common/usbc/usbc_task.c
+++ b/common/usbc/usbc_task.c
@@ -27,6 +27,7 @@
#include "usb_pd_timer.h"
#include "usb_prl_sm.h"
#include "tcpm/tcpm.h"
+#include "usb_pd_dpm_sm.h"
#include "usb_pe_sm.h"
#include "usb_prl_sm.h"
#include "usb_sm.h"
@@ -141,6 +142,10 @@ static bool pd_task_loop(int port)
if (IS_ENABLED(CONFIG_USB_PD_TCPC))
tcpc_run(port, evt);
+ /* Run Device Policy Manager */
+ if (IS_ENABLED(CONFIG_USB_DPM_SM))
+ dpm_run(port, evt, tc_get_pd_enabled(port));
+
/* Run policy engine state machine */
if (IS_ENABLED(CONFIG_USB_PE_SM))
pe_run(port, evt, tc_get_pd_enabled(port));
diff --git a/include/config.h b/include/config.h
index f0b528bead..a0ce35e62c 100644
--- a/include/config.h
+++ b/include/config.h
@@ -4474,10 +4474,12 @@
* TYPEC_SM - Type-C deals with CC lines voltage level connections
* PRL_SM - Protocol handles flow and chunking TX and RX messages
* PE - Policy Engine handles PD communication flow
+ * DPM - Device Policy Manager layer is used to determine port policy
*/
#define CONFIG_USB_TYPEC_SM
#define CONFIG_USB_PRL_SM
#define CONFIG_USB_PE_SM
+#define CONFIG_USB_DPM_SM
/* Enables PD Console commands */
#define CONFIG_USB_PD_CONSOLE_CMD
diff --git a/include/mock/usb_pd_dpm_mock.h b/include/mock/usb_pd_dpm_mock.h
index 8f91cfb390..266cad4aef 100644
--- a/include/mock/usb_pd_dpm_mock.h
+++ b/include/mock/usb_pd_dpm_mock.h
@@ -8,7 +8,7 @@
#define __MOCK_USB_PD_DPM_MOCK_H
#include "common.h"
-#include "usb_pd_dpm.h"
+#include "usb_pd_dpm_sm.h"
/* Defaults should all be 0 values. */
struct mock_dpm_port_t {
diff --git a/include/usb_dp_alt_mode.h b/include/usb_dp_alt_mode.h
index 83dc35b085..1449b96313 100644
--- a/include/usb_dp_alt_mode.h
+++ b/include/usb_dp_alt_mode.h
@@ -15,7 +15,7 @@
#include <stdint.h>
#include "tcpm/tcpm.h"
-#include "usb_pd_dpm.h"
+#include "usb_pd_dpm_sm.h"
/*
* Initialize DP state for the specified port.
diff --git a/include/usb_pd_dpm.h b/include/usb_pd_dpm_sm.h
index c74357d588..8fdd147be1 100644
--- a/include/usb_pd_dpm.h
+++ b/include/usb_pd_dpm_sm.h
@@ -21,6 +21,15 @@
*/
void dpm_init(int port);
+/**
+ * Runs the Device Policy Manager State Machine
+ *
+ * @param port USB-C port number
+ * @param evt system event, ie: PD_EVENT_RX
+ * @param en 0 to disable the machine, 1 to enable the machine
+ */
+void dpm_run(int port, int evt, int en);
+
/*
* Informs the DPM that a mode exit is complete.
*
@@ -43,6 +52,14 @@ void dpm_set_mode_exit_request(int port);
void dpm_data_reset_complete(int port);
/*
+ * Informs the DPM that PE layer is in ready state so that data role can be
+ * checked and DPM can know to exit the idle state.
+ *
+ * @param port USB-C port number
+ */
+void dpm_set_pe_ready(int port, bool enable);
+
+/*
* Informs the DPM that a VDM ACK was received.
*
* @param port USB-C port number
@@ -66,13 +83,6 @@ void dpm_vdm_naked(int port, enum tcpci_msg_type type, uint16_t svid,
uint8_t vdm_cmd);
/*
- * Drives the Policy Engine through entry/exit mode process
- *
- * @param port USB-C port number
- */
-void dpm_run(int port);
-
-/*
* Determines the current allocation for the connection, past the basic
* CONFIG_USB_PD_PULLUP value set by the TC (generally 1.5 A)
*
diff --git a/include/usb_tbt_alt_mode.h b/include/usb_tbt_alt_mode.h
index 378cd0ccce..b7d7baa6a2 100644
--- a/include/usb_tbt_alt_mode.h
+++ b/include/usb_tbt_alt_mode.h
@@ -14,7 +14,7 @@
#include <stdint.h>
#include "tcpm/tcpm.h"
-#include "usb_pd_dpm.h"
+#include "usb_pd_dpm_sm.h"
#include "usb_pd_tcpm.h"
/*
diff --git a/test/fake_usbc.c b/test/fake_usbc.c
index 1d9c42a97a..72a208aa99 100644
--- a/test/fake_usbc.c
+++ b/test/fake_usbc.c
@@ -304,7 +304,7 @@ void dpm_set_mode_exit_request(int port)
{
}
-void dpm_run(int port)
+void dpm_run(int port, int evt, int enable)
{
}
@@ -351,6 +351,10 @@ void dpm_handle_alert(int port, uint32_t ado)
{
}
+void dpm_set_pe_ready(int port, bool enable)
+{
+}
+
static enum tcpc_rp_value lcl_rp;
__overridable void typec_select_src_current_limit_rp(int port,
enum tcpc_rp_value rp)
diff --git a/test/test_config.h b/test/test_config.h
index 3482449c10..a25d8c0845 100644
--- a/test/test_config.h
+++ b/test/test_config.h
@@ -403,6 +403,7 @@ int ncp15wb_calculate_temp(uint16_t adc);
#undef CONFIG_USB_PE_SM
#undef CONFIG_USB_TYPEC_SM
#undef CONFIG_USB_PD_HOST_CMD
+#undef CONFIG_USB_DPM_SM
#define CONFIG_USB_PRL_SM
#define CONFIG_USB_PD_TCPC
#define CONFIG_USB_PD_TCPM_STUB
@@ -423,6 +424,7 @@ int ncp15wb_calculate_temp(uint16_t adc);
#define CONFIG_USB_PD_EXTENDED_MESSAGES
#define CONFIG_USB_PD_TCPMV2
#undef CONFIG_USB_PE_SM
+#undef CONFIG_USB_DPM_SM
#undef CONFIG_USB_TYPEC_SM
#undef CONFIG_USB_PD_HOST_CMD
#define CONFIG_USB_PRL_SM
@@ -531,6 +533,7 @@ int ncp15wb_calculate_temp(uint16_t adc);
#define CONFIG_USB_POWER_DELIVERY
#undef CONFIG_USB_PRL_SM
#undef CONFIG_USB_PE_SM
+#undef CONFIG_USB_DPM_SM
#undef CONFIG_USB_PD_HOST_CMD
#endif
@@ -615,6 +618,7 @@ int ncp15wb_calculate_temp(uint16_t adc);
#define CONFIG_CMD_PD_TIMER
#undef CONFIG_USB_PD_HOST_CMD
#undef CONFIG_USB_PRL_SM
+#undef CONFIG_USB_DPM_SM
#endif
#if defined(TEST_CHARGE_MANAGER) || defined(TEST_CHARGE_MANAGER_DRP_CHARGING)
diff --git a/zephyr/Kconfig.pd b/zephyr/Kconfig.pd
index f6508c2da0..1b104382ad 100644
--- a/zephyr/Kconfig.pd
+++ b/zephyr/Kconfig.pd
@@ -304,6 +304,15 @@ config PLATFORM_EC_USB_PE_SM
USB devices. You should normally define this unless you want to
override it in your board code, which is not recommended.
+config PLATFORM_EC_USB_DPM_SM
+ bool "Device Policy Manager (DPM) state machine"
+ default y
+ help
+ This enables the device policy manager portion of the power-delivery
+ (PD), protocol which is used to define port policy decision. You
+ should normally define this unless you want to override it in your
+ board code, which is not recommended.
+
config PLATFORM_EC_USB_PD_DECODE_SOP
def_bool y # Required for TCPMV2
help
diff --git a/zephyr/shim/include/config_chip.h b/zephyr/shim/include/config_chip.h
index 1bc00a0516..bfef3427a8 100644
--- a/zephyr/shim/include/config_chip.h
+++ b/zephyr/shim/include/config_chip.h
@@ -1330,6 +1330,11 @@ extern char mock_jump_data[sizeof(struct jump_data) + 256];
#define CONFIG_USB_PE_SM
#endif
+#undef CONFIG_USB_DPM_SM
+#ifdef CONFIG_PLATFORM_EC_USB_DPM_SM
+#define CONFIG_USB_DPM_SM
+#endif
+
#undef CONFIG_USB_PD_DECODE_SOP
#ifdef CONFIG_PLATFORM_EC_USB_PD_DECODE_SOP
#define CONFIG_USB_PD_DECODE_SOP
diff --git a/zephyr/test/drivers/default/src/console_cmd/usb_pd_console.c b/zephyr/test/drivers/default/src/console_cmd/usb_pd_console.c
index d521f7bb06..a63e2de496 100644
--- a/zephyr/test/drivers/default/src/console_cmd/usb_pd_console.c
+++ b/zephyr/test/drivers/default/src/console_cmd/usb_pd_console.c
@@ -11,7 +11,7 @@
#include "test/drivers/test_state.h"
#include "test/drivers/utils.h"
#include "usb_pd.h"
-#include "usb_pd_dpm.h"
+#include "usb_pd_dpm_sm.h"
#include "usb_prl_sm.h"
static void console_cmd_usb_pd_after(void *fixture)