Skip to content

Commit 9b021bc

Browse files
Johan Carlssonkartben
authored andcommitted
usb-c: add PE_SRC_Disabled support.
with this fix the pd stack works with type-c devices that does not respond to pd. Signed-off-by: Johan Carlsson <johan.carlsson@teenage.engineering>
1 parent cae6731 commit 9b021bc

File tree

4 files changed

+32
-3
lines changed

4 files changed

+32
-3
lines changed

subsys/usb/usb_c/usbc_pe_common.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1371,6 +1371,12 @@ static const struct smf_state pe_states[PE_STATE_COUNT] = {
13711371
pe_src_ready_exit,
13721372
NULL,
13731373
NULL),
1374+
[PE_SRC_DISABLED] = SMF_CREATE_STATE(
1375+
pe_src_disabled_entry,
1376+
NULL,
1377+
NULL,
1378+
NULL,
1379+
NULL),
13741380
[PE_SRC_TRANSITION_TO_DEFAULT] = SMF_CREATE_STATE(
13751381
pe_src_transition_to_default_entry,
13761382
pe_src_transition_to_default_run,

subsys/usb/usb_c/usbc_pe_common_internal.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,8 @@ enum usbc_pe_state {
8383
PE_SRC_TRANSITION_SUPPLY,
8484
/** PE_SRC_Ready */
8585
PE_SRC_READY,
86+
/** PE_SRC_Disabled */
87+
PE_SRC_DISABLED,
8688
/** PE_SRC_Hard_Reset */
8789
PE_SRC_HARD_RESET,
8890
/** PE_SRC_Hard_Reset_Received */

subsys/usb/usb_c/usbc_pe_src_states.c

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -154,9 +154,12 @@ void pe_src_discovery_run(void *obj)
154154
* 1) The SourceCapabilityTimer times out
155155
* 2) And CapsCounter ≤ nCapsCount
156156
*/
157-
if (usbc_timer_expired(&pe->pd_t_typec_send_source_cap)
158-
&& pe->caps_counter <= PD_N_CAPS_COUNT) {
159-
pe_set_state(dev, PE_SRC_SEND_CAPABILITIES);
157+
if (usbc_timer_expired(&pe->pd_t_typec_send_source_cap)) {
158+
if (pe->caps_counter <= PD_N_CAPS_COUNT) {
159+
pe_set_state(dev, PE_SRC_SEND_CAPABILITIES);
160+
} else {
161+
pe_set_state(dev, PE_SRC_DISABLED);
162+
}
160163
}
161164
}
162165

@@ -483,6 +486,19 @@ void pe_src_ready_exit(void *obj)
483486
}
484487
}
485488

489+
/**
490+
* @brief 8.3.3.2.7 PE_SRC_Disabled State
491+
*/
492+
void pe_src_disabled_entry(void *obj)
493+
{
494+
LOG_INF("PE_SRC_Disabled");
495+
496+
/*
497+
* Unresponsive to USB Power Delivery messaging, but not to Hard Reset
498+
* Signaling. See pe_got_hard_reset
499+
*/
500+
}
501+
486502
/**
487503
* @brief 8.3.3.2.11 PE_SRC_Transition_to_default State
488504
*/

subsys/usb/usb_c/usbc_pe_src_states_internal.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,11 @@ void pe_src_ready_entry(void *obj);
5757
void pe_src_ready_run(void *obj);
5858
void pe_src_ready_exit(void *obj);
5959

60+
/**
61+
* @brief PE_SRC_Disabled State
62+
*/
63+
void pe_src_disabled_entry(void *obj);
64+
6065
/**
6166
* @brief PE_SRC_Transition_To_Default State
6267
*/

0 commit comments

Comments
 (0)