usbc: check if sampling CC lines were successful
When the get_cc function returns error, the CC lines should be considered as open. It may happen either due to some chip malfunction or chip going into sleep mode and needing time to reinitialize. TCPC should only go to sleep if there is no partner attaches, so in case of this error, the lines should be considered as disconnected. Signed-off-by: Michał Barnaś <mb@semihalf.com>
This commit is contained in:
parent
0f4eb42c97
commit
cff8bb2687
|
@ -70,7 +70,14 @@ void tc_run(const struct device *dev, const int32_t dpm_request)
|
|||
}
|
||||
|
||||
/* Sample CC lines */
|
||||
tcpc_get_cc(tcpc, &tc->cc1, &tc->cc2);
|
||||
if (tcpc_get_cc(tcpc, &tc->cc1, &tc->cc2) != 0) {
|
||||
/* If this function fails, it may mean that the TCPC is in sleep mode or
|
||||
* the communication with TCPC has failed, so we can assume that the CC
|
||||
* lines are open or existing connection is faulty.
|
||||
*/
|
||||
tc->cc1 = TC_CC_VOLT_OPEN;
|
||||
tc->cc2 = TC_CC_VOLT_OPEN;
|
||||
}
|
||||
|
||||
/* Detect polarity */
|
||||
tc->cc_polarity = (tc->cc1 > tc->cc2) ? TC_POLARITY_CC1 : TC_POLARITY_CC2;
|
||||
|
|
Loading…
Reference in a new issue