|
@@ -42,6 +42,7 @@ enum policy_engine_state {
|
42
|
42
|
PESinkSoftReset,
|
43
|
43
|
PESinkSendSoftReset,
|
44
|
44
|
PESinkSendNotSupported,
|
|
45
|
+ PESinkChunkReceived,
|
45
|
46
|
PESinkSourceUnresponsive
|
46
|
47
|
};
|
47
|
48
|
|
|
@@ -404,7 +405,24 @@ static enum policy_engine_state pe_sink_ready(struct pdb_config *cfg)
|
404
|
405
|
chPoolFree(&pdb_msg_pool, cfg->pe._message);
|
405
|
406
|
cfg->pe._message = NULL;
|
406
|
407
|
return PESinkSoftReset;
|
407
|
|
- /* If we got an unknown message, send a soft reset */
|
|
408
|
+ /* PD 3.0 messges */
|
|
409
|
+ } else if ((cfg->pe.hdr_template & PD_HDR_SPECREV) == PD_SPECREV_3_0) {
|
|
410
|
+ /* If the message is a multi-chunk extended message, let it
|
|
411
|
+ * time out. */
|
|
412
|
+ if ((cfg->pe._message->hdr & PD_HDR_EXT)
|
|
413
|
+ && (PD_DATA_SIZE_GET(cfg->pe._message) > PD_MAX_EXT_MSG_LEGACY_LEN)) {
|
|
414
|
+ chPoolFree(&pdb_msg_pool, cfg->pe._message);
|
|
415
|
+ cfg->pe._message = NULL;
|
|
416
|
+ return PESinkChunkReceived;
|
|
417
|
+ /* If we got an unknown message, send a soft reset */
|
|
418
|
+ } else {
|
|
419
|
+ chPoolFree(&pdb_msg_pool, cfg->pe._message);
|
|
420
|
+ cfg->pe._message = NULL;
|
|
421
|
+ return PESinkSendSoftReset;
|
|
422
|
+ }
|
|
423
|
+ /* If we got an unknown message, send a soft reset
|
|
424
|
+ *
|
|
425
|
+ * XXX I don't like that this is duplicated. */
|
408
|
426
|
} else {
|
409
|
427
|
chPoolFree(&pdb_msg_pool, cfg->pe._message);
|
410
|
428
|
cfg->pe._message = NULL;
|
|
@@ -633,6 +651,21 @@ static enum policy_engine_state pe_sink_send_not_supported(struct pdb_config *cf
|
633
|
651
|
return PESinkReady;
|
634
|
652
|
}
|
635
|
653
|
|
|
654
|
+static enum policy_engine_state pe_sink_chunk_received(struct pdb_config *cfg)
|
|
655
|
+{
|
|
656
|
+ (void) cfg;
|
|
657
|
+
|
|
658
|
+ /* Wait for tChunkingNotSupported */
|
|
659
|
+ eventmask_t evt = chEvtWaitAnyTimeout(PDB_EVT_PE_RESET,
|
|
660
|
+ PD_T_CHUNKING_NOT_SUPPORTED);
|
|
661
|
+ /* If we got reset signaling, transition to default */
|
|
662
|
+ if (evt & PDB_EVT_PE_RESET) {
|
|
663
|
+ return PESinkTransitionDefault;
|
|
664
|
+ }
|
|
665
|
+
|
|
666
|
+ return PESinkSendNotSupported;
|
|
667
|
+}
|
|
668
|
+
|
636
|
669
|
/*
|
637
|
670
|
* When Power Delivery is unresponsive, fall back to Type-C Current
|
638
|
671
|
*/
|
|
@@ -717,6 +750,9 @@ static THD_FUNCTION(PolicyEngine, vcfg) {
|
717
|
750
|
case PESinkSendNotSupported:
|
718
|
751
|
state = pe_sink_send_not_supported(cfg);
|
719
|
752
|
break;
|
|
753
|
+ case PESinkChunkReceived:
|
|
754
|
+ state = pe_sink_chunk_received(cfg);
|
|
755
|
+ break;
|
720
|
756
|
case PESinkSourceUnresponsive:
|
721
|
757
|
state = pe_sink_source_unresponsive(cfg);
|
722
|
758
|
break;
|