Skip to content

Commit 51c7225

Browse files
Josh-Tsaiquinchou77
authored andcommitted
fwk: ucsi: workaround: do not bypass the invalid UCSI data to host
PD chip will set the negotiated_power_level_change when the port is disconnected. But the UCSI specification describes that this bit shall be set by the PPM whenever a Power contract is established or renegotiated. This is a workaround to clear the invalid data format to pass the HLK test item: "UCSI Get Connector Status - Negotiated Power Level Change [Type-C MUTT]" BRANCH=fwk-main BUG=https://app.clickup.com/t/86etqf4jh BUG=https://app.clickup.com/t/86er6n76t BUG=https://app.clickup.com/t/86etjdkpx TEST=Run the HLK test item "UCSI Get Connector Status - Negotiated Power Level Change [Type-C MUTT]" can get the pass result with all type-c ports Signed-off-by: Josh Tsai <Josh_Tsai@compal.com> (cherry picked from commit 9ebd468d4281a83ccb726f58727d6dd721dba398)
1 parent 61bafd3 commit 51c7225

1 file changed

Lines changed: 31 additions & 5 deletions

File tree

  • zephyr/program/framework/src

zephyr/program/framework/src/ucsi.c

Lines changed: 31 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -557,11 +557,37 @@ void check_ucsi_event_from_host(void)
557557
}
558558
}
559559

560-
if (command == UCSI_CMD_GET_CONNECTOR_STATUS &&
561-
(((uint8_t *)message_in)[8] & 0x03) > 1) {
562-
CPRINTS("Overriding Slow charger status");
563-
/* Override not charging value with nominal charging */
564-
((uint8_t *)message_in)[8] = (((uint8_t *)message_in)[8] & 0xFC) + 1;
560+
/* Clear the ACK_CC_CI connector change indicator field */
561+
if (command == UCSI_CMD_ACK_CC_CI)
562+
*cci &= 0xffffff00;
563+
564+
if (command == UCSI_CMD_GET_CONNECTOR_STATUS) {
565+
566+
int connect_status = (((uint8_t *)message_in)[2] & 0x08) >> 3;
567+
int negotiated_power_level_change =
568+
(((uint8_t *)message_in)[0] & 0x40) >> 6;
569+
570+
if ((((uint8_t *)message_in)[8] & 0x03) > 1) {
571+
CPRINTS("Overriding Slow charger status");
572+
/* Override not charging value with nominal charging */
573+
((uint8_t *)message_in)[8] =
574+
(((uint8_t *)message_in)[8] & 0xFC) + 1;
575+
}
576+
577+
/**
578+
* PD chip will set the negotiated_power_level_change when the port
579+
* is disconnected. But the UCSI specification describes that this
580+
* bit shall be set by the PPM whenever a Power contract is established
581+
* or renegotiated.
582+
*
583+
* This is a workaround to clear the invalid data format to pass the
584+
* HLK test item: "UCSI Get Connector Status - Negotiated Power Level
585+
* Change [Type-C MUTT]"
586+
*/
587+
if (negotiated_power_level_change && !connect_status) {
588+
((uint8_t *)message_in)[0] =
589+
(((uint8_t *)message_in)[0] & 0xBF);
590+
}
565591
}
566592

567593
crec_msleep(2);

0 commit comments

Comments
 (0)