|
@@ -65,14 +65,10 @@ bool pdbs_dpm_evaluate_capability(struct pdb_config *cfg,
|
65
|
65
|
if (scfg != NULL && dpm_data->output_enabled) {
|
66
|
66
|
/* Look at the PDOs to see if one matches our desires */
|
67
|
67
|
for (uint8_t i = 0; i < numobj; i++) {
|
68
|
|
- /* Fixed Supply PDOs come first, so when we see a PDO that isn't a
|
69
|
|
- * Fixed Supply, stop reading. */
|
70
|
|
- if ((capabilities->obj[i] & PD_PDO_TYPE) != PD_PDO_TYPE_FIXED) {
|
71
|
|
- break;
|
72
|
|
- }
|
73
|
|
- /* If the V from the PDO equals our desired V and the I is at least
|
74
|
|
- * our desired I */
|
75
|
|
- if (PD_PDO_SRC_FIXED_VOLTAGE_GET(capabilities, i) == PD_MV2PDV(scfg->v)
|
|
68
|
+ /* If we have a fixed PDO, its V equals our desired V, and its I is
|
|
69
|
+ * at least our desired I */
|
|
70
|
+ if ((capabilities->obj[i] & PD_PDO_TYPE) == PD_PDO_TYPE_FIXED
|
|
71
|
+ && PD_PDO_SRC_FIXED_VOLTAGE_GET(capabilities, i) == PD_MV2PDV(scfg->v)
|
76
|
72
|
&& PD_PDO_SRC_FIXED_CURRENT_GET(capabilities, i) >= scfg->i) {
|
77
|
73
|
/* We got what we wanted, so build a request for that */
|
78
|
74
|
request->hdr = cfg->pe.hdr_template | PD_MSGTYPE_REQUEST
|
|
@@ -96,6 +92,31 @@ bool pdbs_dpm_evaluate_capability(struct pdb_config *cfg,
|
96
|
92
|
/* Update requested voltage */
|
97
|
93
|
dpm_data->_requested_voltage = PD_PDV2MV(PD_MV2PDV(scfg->v));
|
98
|
94
|
|
|
95
|
+ dpm_data->_capability_match = true;
|
|
96
|
+ return true;
|
|
97
|
+ }
|
|
98
|
+ /* If we have a PPS APDO, our desired V lies within its range, and
|
|
99
|
+ * its I is at least our desired I */
|
|
100
|
+ if ((capabilities->obj[i] & PD_PDO_TYPE) == PD_PDO_TYPE_AUGMENTED
|
|
101
|
+ && (capabilities->obj[i] & PD_APDO_TYPE) == PD_APDO_TYPE_PPS
|
|
102
|
+ && PD_APDO_SRC_PPS_MAX_VOLTAGE_GET(capabilities, i) >= PD_MV2PAV(scfg->v)
|
|
103
|
+ && PD_APDO_SRC_PPS_MIN_VOLTAGE_GET(capabilities, i) <= PD_MV2PAV(scfg->v)
|
|
104
|
+ && PD_APDO_SRC_PPS_CURRENT_GET(capabilities, i) >= PD_CA2PAI(scfg->i)) {
|
|
105
|
+ /* We got what we wanted, so build a request for that */
|
|
106
|
+ request->hdr = cfg->pe.hdr_template | PD_MSGTYPE_REQUEST
|
|
107
|
+ | PD_NUMOBJ(1);
|
|
108
|
+
|
|
109
|
+ /* Build a request */
|
|
110
|
+ request->obj[0] = PD_RDO_PROG_CURRENT_SET(PD_CA2PAI(scfg->i))
|
|
111
|
+ | PD_RDO_PROG_VOLTAGE_SET(PD_MV2PRV(scfg->v))
|
|
112
|
+ | PD_RDO_NO_USB_SUSPEND | PD_RDO_OBJPOS_SET(i + 1);
|
|
113
|
+ if (dpm_data->usb_comms) {
|
|
114
|
+ request->obj[0] |= PD_RDO_USB_COMMS;
|
|
115
|
+ }
|
|
116
|
+
|
|
117
|
+ /* Update requested voltage */
|
|
118
|
+ dpm_data->_requested_voltage = PD_PRV2MV(PD_MV2PRV(scfg->v));
|
|
119
|
+
|
99
|
120
|
dpm_data->_capability_match = true;
|
100
|
121
|
return true;
|
101
|
122
|
}
|